在ARC環境中,我有以下代碼:類型轉換導致編譯器錯誤
NSInvocation* invocation = [NSInvocation invocationWithMethodSignature:signature];
[invocation setTarget:delegate];
[invocation setSelector:@selector(restClient:loadedFile:contentType:eTag:)];
// Error Here!
[invocation setArgument:&self atIndex:2];
[invocation setArgument:&filename atIndex:3];
[invocation setArgument:&contentType atIndex:4];
[invocation setArgument:&eTag atIndex:5];
參數設置爲索引2(&self
)導致以下編譯器錯誤:
Sending *const __strong * to parameter of type void * changes retain/release properties
我不知道如何解決這個問題,同時保持有效的代碼。目前我只是堅持在NULL
並將try語句包裝在try/catch塊中,但這是一個不太理想的解決方案。
類似的問題,如果有人是一種足以解決這一問題,以及:
有了這行代碼(從MPOAuth庫)
status = SecItemCopyMatching((__bridge CFDictionaryRef)searchDictionary, (CFTypeRef *)&attributesDictionary);
我收到以下錯誤
Cast of an indirect pointer to an Objective-C pointer to 'CFTypeRef ' (aka 'const void *') is disallowed with ARC
是否有一些特定的原因,你爲什麼要在這裏使用NSInvocation而不是塊? – NSResponder
我不確定,它是Dropbox SDK的一部分。我只是讓它符合ARC標準,儘量不要搞亂代碼。 – FeifanZ