Frage

This question is sparked by a response to: Should NSInteger really be used everywhere?

I'm still trying to wrap my head around the implications of using NSInteger for small values, especially now that NSInteger converts to long in a 64-bit environment. I come from the school of thought that says you want to use the smallest possible memory space for maximum efficiency. So, for example, if you know for sure that a variable will only ever hold a value of 0 to 5, then you would use a short, or in the case of Objective-C, int. But you would never use a long because that's just wasteful.

But of course best practice in Objective-C has always been to use NSInteger and NSUInteger, to "future proof" for 64-bit. Now that it's here (referring specifically to iPhone 5S), that small 0 to 5 number that I declared as NSInteger is now being saved in a long 64-bit space.

Maybe it's my lack of a degree, but I'm having a hard time understanding how this is a good thing. Can someone explain it in remedial terms or post a relevant link?

Keine korrekte Lösung

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top