Anyone have the expertise to explain when to use NSUInteger and when to use NSInteger?
I had seen Cocoa methods returning NSInteger even in cases where the returned
By default, an integer is assumed to be signed. In other words the compiler assumes that an integer variable will be called upon to store either a negative or positive number. This limits the extent that the range can reach in either direction. For example, a 32-bit int has a range of 4,294,967,295. In practice, because the value could be positive or negative the range is actually −2,147,483,648 to +2,147,483,647. If we know that a variable will never be called upon to store a negative value, we can declare it as unsigned, thereby extending the (positive) range to 0 to +4,294,967,295. So i would say, its okay to use NSInteger when you know that you have a restricted output range. I personally use NSUInteger if I needed to return really big positive only numbers