In un ambiente ARC, ho il seguente codice:Tipo conversione del & sé provoca errore del compilatore
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];
Impostare l'argomento di indice 2 (&self
) causa il seguente errore del compilatore:
Sending *const __strong * to parameter of type void * changes retain/release properties
Non ho idea di come risolvere questo problema mantenendo il codice valido. Al momento sto semplicemente inserendo NULL
e avvolgendo l'istruzione invoke in un blocco try/catch, ma questa è una soluzione tutt'altro che ideale.
Un problema simile, se qualcuno sarebbe così gentile da affrontare pure:
Con questa riga di codice (dalla libreria MPOAuth)
status = SecItemCopyMatching((__bridge CFDictionaryRef)searchDictionary, (CFTypeRef *)&attributesDictionary);
ottengo il seguente errore
Cast of an indirect pointer to an Objective-C pointer to 'CFTypeRef ' (aka 'const void *') is disallowed with ARC
C'è qualche motivo particolare per cui si desidera utilizzare NSInvocation anziché un blocco qui? – NSResponder
Non sono sicuro, fa parte dell'SDK Dropbox. Sto solo verificando che sia compatibile con ARC, cercando di non rovinare troppo il codice. – FeifanZ