Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I place an __NSCFNumber in an NSString? [closed]

I have an NSNumber variable called task_id. I want to place that NSNumber variable in an NSString (post request). Here is what I have tried:

NSString *post = [NSString stringWithFormat:@"&task_id=%@", task_id];

and:

NSString *post = [NSString stringWithFormat:@"&task_id=%@", [NSString stringWithFormat:@"%@",task_id]];

For some reason the string doesn't include the task_id value to the POST request. How can I place the NSNumber into the string?

Update

task_id is an NSCFNumber according to this code:

NSLog(@"%@", [task_id class]);

Many thanks indeed,

Peter

like image 800
Peter Stuart Avatar asked Feb 24 '14 17:02

Peter Stuart


1 Answers

NSNumber *myNumber = @12;
NSString *myString = [myNumber stringValue];
NSString *post = [NSString stringWithFormat:@"&task_id=%@", myString];

It was already answered here

like image 96
zaheer Avatar answered Sep 30 '22 05:09

zaheer