I’m new to objective C and I just wanted to get a general clarification on when to use a pointer and when not to, when declaring instance variables.
The example I can think of is UIView vs. a BOOL. UIView I would make a pointer, BOOL I would not (because the compiler yelled at me).
Any general guidance would be awesome.
Cheers,
If it’s an object, you use pointer notation. All of the c types (int, BOOL, long, etc) are not objects and thus you only use a pointer if you want a pointer to their memory location:
A special case is
id, which is itself a pointer to an object, so you don’t need the*:Slightly tricky:
NSInteger is the appropriate platform-specific int type, whereas NSNumber is an object that can contain an int, float, or what have you.