How to get the pointers to an id variable and an NSObject pointer?
id idPointer = [[SomeObject al开发者_开发百科loc] init];
NSObject *nsPointer = [[SomeObject alloc] init];
How do I get the pointers of idPointer
and nsPointer
?
To get pointers to pointers it just requires an extra *
on the variable. And to assign them you will usually get the address of a normal pointer &
. And then dereference them again with *
in front.
//Declare and Assign them
id *idPointerPointer = &idPointer;
NSObject **nsPointerPointer = &nsPointer;
//Dereference them (just an example to send a message)
[*idPointerPointer release];
[*nsPointerPointer release];
精彩评论