在 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
) 会导致以下编译器错误:
将 *const __strong * 发送到 void * 类型的参数会更改保留/释放属性
我不知道如何在保持有效代码的同时解决这个问题。目前我只是坚持NULL
并将调用语句包装在 try/catch 块中,但这是一个不太理想的解决方案。
类似的问题,如果有人也愿意解决它:
使用这行代码(来自 MPOAuth 库)
status = SecItemCopyMatching((__bridge CFDictionaryRef)searchDictionary, (CFTypeRef *)&attributesDictionary);
我收到以下错误
ARC 不允许使用指向“CFTypeRef ”(又名“const void * ”)的 Objective-C 指针的间接指针强制转换