开发者

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];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜