I was recently writing a program in Objective-C and I tried the wrote the following part of a line where ‘someString’ is an instance of NSString:
[someString substringFromIndex:3];
The compiler seems okay with this but I’m not exactly sure why. The documentation for the substringFromIndex method says that the parameter has to be an NSUInteger however, isn’t 3 just a primitive integer? Why can I do this? (Note, I’m new to Objective-C so I’m sure the reasoning is very simple or I’m just wrong about something.)
NSUIntegeris typedef’d to a primitive type. Which type it is depends on the processor you’re compiling for.As seen here (and pasted below):