small medium large xlarge

17 Oct 2011, 03:06
Stephen Castle (1 post)

I’ve noticed some variables do not have the * in front of them, for example pg 296 Chapter 12. NSRect viewBounds =[self bounds]; I always thought a variable had to be prefixed with an *. like NSColor *currentColor. Is their a rule of thumb when and when not to use the * ? Is it because NSRect is not an object? it’s a C struct ?


17 Oct 2011, 11:32
Tim Isted (105 posts)

Yes - the asterisk is used for a pointer, usually a pointer to an Objective-C object; no asterisk is used for a “scalar variable.”

I’d suggest re-reading Chapter 5 on variables and memory, specifically section 5.5 “Pointers Again” and its section “Follow the Pointing Star.”