Reputation: 6940
That may sound odd.
I got an NSString value NSString * numb = [self.dataDict valueForKey:@"id"];
and i know, that is it some kind of integer (for example, i need that integer to comparison - if val less or equal then something). I need to know what integer is it.
What i've tried:
NSNumber *numba = [self.dataDict valueForKey:@"id"];
NSLog output - numba is 2038735264
And actually that was 428.
is there any way to achieve the point? Thanks!
That is piece of responseObject:
( { id = 3; dog = "\U041a\U0430\U043a\U043e\U0439-\U0442\U043e \U043c\U0443\U0434\U0430\U043a \U043d\U0430\U043a\U0440\U0443\U0442\U0438\U043b"; image = "cute_dog/116.jpg"; score = 586; }, { id = 115; dog = "\U0422\U0430\U043d\U044f \U041a\U043b\U044e\U043a\U0432\U0438\U043d\U0430"; image = "cute_dog/115.jpg"; score = 481; },
Upvotes: 0
Views: 1811
Reputation: 744
Trying something like this.
NSNumber *numba = [NSNumber numberWithInt[self.dataDict valueForKey:@"id"]];
//For string
NSString *stringValue = [numba stringValue];
//For integer
NSInteger integer = [numba integerValue];
Upvotes: 1
Reputation: 385500
There are a number of methods you can use to convert an NSString
to a number. What numeric type would you like?
NSString *string = self.dataDict[@"id"];
int intValue = string.intValue;
NSInteger integerValue = string.integerValue;
long long longLongValue = string.longLongValue;
Upvotes: 6