9

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、invokeステートメントをtry / catchブロックに固定してラップしているだけですが、これは理想的とは言えない解決策です。


同様の問題、誰かがそれに対処するのに十分親切であるならば:

このコード行(MPOAuthライブラリから)

status = SecItemCopyMatching((__bridge CFDictionaryRef)searchDictionary, (CFTypeRef *)&attributesDictionary);

次のエラーが発生します

'CFTypeRef '(別名'const void * ')へのObjective-Cポインターへの間接ポインターのキャストはARCでは許可されていません

4

3 に答える 3

13

適切なポインタタイプを取得するためにキャストできるはずです。

NSInvocation* invocation = [NSInvocation invocationWithMethodSignature:signature];
[invocation setTarget:delegate];
[invocation setSelector:@selector(restClient:loadedFile:contentType:eTag:)];
Foo *foo = self;
[invocation setArgument:&foo atIndex:2];
[invocation setArgument:&filename atIndex:3];
[invocation setArgument:&contentType atIndex:4];
[invocation setArgument:&eTag atIndex:5];
于 2011-09-27T05:24:09.480 に答える
2

この行:

 status = SecItemCopyMatching((__bridge CFDictionaryRef)searchDictionary, (CFTypeRef *)&attributesDictionary);

次のように解決できます。

 CFTypeRef outDictionaryRef;
 status = SecItemCopyMatching((__bridge CFDictionaryRef)searchDictionary, &outDictionaryRef;
 attributesDictionary = (__bridge_transfer NSDictionary *) outDictionaryRef;

したがって、本質的には、outパラメータとして期待する参照タイプを指定するだけです。そして、outパラメータが入力されたら、所有権をココアタイプに譲渡します。

于 2011-12-09T14:11:39.697 に答える
0

SDKを変更するのではなく(DropboxはARC互換バージョンをまもなく投稿すると言っています)、ファイルに対してARCを選択的に使用できることがわかりました。だから私はそれをしました。

次に、ライブラリとしてパッケージ化されている1.0b2にアップグレードしたので、問題は解決しました。

于 2011-09-29T15:24:31.270 に答える