I’ve got an id* type and would like to cast it to an NSString * – with ARC enabled. How do I achieve this?
EDIT:
This doesn’t work… how should I adapt this to make it work?
id *idStar = ...;
NSString **string2Star = (NSString **) idStar;
NSLog(@"%@", *string2Star);
id *can’t be cast toNSString *under any circumstances.Keep in mind that
idis already a pointer type; making it equivalent not toNSString, but toNSString *.In order to cast, you’d have to cast it to
NSString **.Edit:
In the case you are presenting, the cast is completely unnecessary.
should do nicely; and even that’s moderately unnecessary.
Keep in mind that the variable type in Objective-C basically is nothing more than a hint to the compiler to let it know what methods you are planning to call; and warn you if you call different ones.
The actual method call mapping all happens at runtime; meaning that casts are fairly meaningless.