This piece of code used to compile fine in non-ARC:
int *privateObjMemory = (int *)[myObject performSelector:@selector(privateMethod)];
now I am in ARC I get:
Cast of an Objective-C pointer to ‘int *’ is disallowed with ARC
How could I fix this? 🙂
Write it as:
😉
The reason you want to avoid this is that it’s ambiguous to ARC.
performSelector:returns an object — should thatint*be retained? hmmm… no.Update
Based on comments, and removing previous writing:
But that’s not a very good solution. If you are calling a specific private API, then you must know its signature (e.g. parameter and return types). If it is your private API, then figure out a way to make that private interface visible selectively.
If it is somebody else’s private API, then declare a category on the type which has the correct parameters and return type.
Then the selector is declared properly, and the compiler will be able to setup the call correctly by messaging the object directly — without the need for using
performSelector:.