I'm new to Objective-C and Cocoa. I've read that NSInteger and NSNumber are preferred when working with simple integers because they're the "platform-safe" versions of the primitive numeric types (and in NSNumber's case, wrapped in an object). So, I need a counter in my class that gets incremented when an NSTimer fires. On an Apple forum I found a group of people all recommending to someone in a similar situation that they should declare a NSNumber pointer in the header, initialize it with numberWithInt:, and then each time it needs to be incremented do so by assigning it to a new object (something like counter = [NSNumber numberWithInt:[counter intValue]+1];
). This looks like overkill to me. If all I need is an int counter (and btw, I'm resetting it back to 0 after it hits 15 so size isn't an issue), can't I get away with just using an int and not have to allocate a new object with each iteration of my timer's loop?
And if so, how do I make a primitive type available throughout my class. I know that with object types, I declare it in my interface and use @property and @synthesize...what's the equivalent (if one exists) when working with primitives?