I really can't figure out how to convert large NSNumber to NSString (4h googling not solved my problem and tried all suggested solutions - stringValue, NSNumberFormatter, NSDecimalNumber).
Currently I converting in this way:
[NSString stringWithFormat:@"%llu", [largeNumber unsignedLongLongValue]];
All works fine with small numbers but with larger I get wrong strings :( Example: Input number is 10202713632509569, but returned string is 10202713632509568. How to convert NSNumber to NSString in proper way?
I get NSNumber from JSON response with AFNetworking framework.
My JSON:
{
"author": {
"name": "Open Graph Test User",
"social_type": "facebook",
"id": 10202713632509569
}
}
My code:
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager new];
manager.responseSerializer = [AFJSONResponseSerializer new];
[manager GET:@"/api/author"
parameters:nil
success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSNumber *largeNumber = responseObject[@"author"][@"social_id"];
// ...
NSString *callPath = [NSString stringWithFormat:@"/profile/%@/%@", _userSocialType, [NSString stringWithFormat:@"%llu", [largeNumber unsignedLongLongValue]]];
// ...
}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
// ...
}
}];