开发者

Why is there no * in this method declaration?

开发者 https://www.devze.com 2023-01-03 08:47 出处:网络
Here is the method declaration midway in Apple\'s documentation: Learning Objective-C: A Primer - (void)insertObject:(id) anObject atIndex:(NSUInteger) index

Here is the method declaration midway in Apple's documentation: Learning Objective-C: A Primer

- (void)insertObject:(id) anObject atIndex:(NSUInteger) index

Why is there no * right after NSUInteger. I thought all objects were pointer types and all strongly typed pointers had to have 开发者_开发问答a * character after it.


NSUInteger is not an object type, it is a typedef to unsigned int.

The only reason that you would actually want to use a * in this context would be if you wanted to get the address of an int and store something in it. (Some libraries do this with error messaging). An example of this:

-(void) methodName: (NSUInteger *) anInt {
    *anInt = 5;
}

NSUInteger a;
[obj methodName: &a]; //a is now 5
0

精彩评论

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