My application gets an NSString containing an unsigned int . NSString does not have a method [myString unsignedIntegerValue]; . I would like to be able to extract a value from a string without distorting it, and then place it inside NSNumber . I am trying to do it like this:
NSString *myUnsignedIntString = [self someMethodReturningAString]; NSInteger myInteger = [myUnsignedIntString integerValue]; NSNumber *myNSNumber = [NSNumber numberWithInteger:myInteger];
Will the above potentially "cut off" the end of a large unsigned int since I had to convert it to NSInteger ? Or does it look normal? If this cuts off the end, then what about the next one (a bit like kludge)?
NSString *myUnsignedIntString = [self someMethodReturningAString]; long long myLongLong = [myUnsignedIntString longLongValue]; NSNumber *myNSNumber = [NSNumber numberWithLongLong:myLongLong];
Thanks for any help you can offer! :)
objective-c cocoa nsstring unsigned
Dave gallagher
source share