Nat! bio photo


Senior Mull

Twitter Github Twitch

NSInteger ? Why not just int ?

Being old enough to have witnessed the migration from 16 bit int to bit int, I assumed that eventually int would become 64 bit. With this NSInteger thingy, it's been a big surprise. Because if int had just naturally grown to 64 bit, we wouldn't need this NSInteger at all.

I think somewhere in the C-Standard it even says, that int can be expected to be the "natural" fit for the CPU.

That the Cocoa APIs were designed using int and unsigned int for years instead of using size_t or some such like the rest of the world, to me only ever made sense, if indeed int was basically used as the migration type. That's one of the main features of C to define types not strictly as having a certain size, expressly intended for upwards migration... to belabor that point.

If I were to change all by ints to NSInteger using that tops script, I'd have the identical runtime problems as if the compiler had changed the meaning from 32 bit to 64 bit.

So where's the benefit ?

Post a comment

All comments are held for moderation; basic HTML formatting accepted.

E-mail: (not published)