tags:

views:

34

answers:

1

I know that the "-length" method returns an int. Is there any other method that works the same as the "-length" method but returns as an NSInteger or an NSString?

+2  A: 

you can get a NSString from the NSUInteger that the length method retruns

stringresult = [NSString stringWithFormat:@"%u",[@"my string" length]];

with this, you can make your own method...

and here you can find more about Format Specifiers

mklfarha
Technically that's not a cast. Also, the format specifier is wrong. The return type of -length is NSUInteger. This is a 32 or 64 bit unsigned quantity, but %i is for signed 32 bit integers.
JeremyP
yes i was just thinking about that it is not technically a cast sorry about that, and about the format specifier yes %i is for a signed int and NSUInteger uses unsigned int...
mklfarha