문제

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

도움이 되었습니까?

해결책 3

Thanks for everyones efforts. It turns out that wasn't the problem, and the problems lies within the web server!

I misunderstood the whole thing,

Thanks guys,

Peter

다른 팁

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

It was already answered here

it should work.But anyway, if task-id is just an int ,

NSString *post = [NSString stringWithFormat:@"&task_id=%d", task_id.intValue];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top