views:

146

answers:

1

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 * after it.

+10  A: 

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
Jacob Relkin
Two errors: NSInteger/NSUInteger/CFindex are 64-bit types on 64-bit systems, since they're used to represent stuff like lengths/counts/offsets of stuff in memory. Also, you mean *anInt = 5.
tc.
harms
Jacob Relkin