我有一个名为task_id的NSNumber变量.我想将NSNumber变量放在NSString(post请求)中.这是我尝试过的: NSString *post = [NSString stringWithFormat:@"task_id=%@", task_id]; 和: NSString *post = [NSString stringWithFormat
NSString *post = [NSString stringWithFormat:@"&task_id=%@", task_id];
和:
NSString *post = [NSString stringWithFormat:@"&task_id=%@", [NSString stringWithFormat:@"%@",task_id]];
由于某种原因,字符串不包含POST请求的task_id值.如何将NSNumber放入字符串?
更新
task_id是根据此代码的NSCFNumber:
NSLog(@"%@", [task_id class]);
非常感谢,
彼得
NSNumber *myNumber = @12; NSString *myString = [myNumber stringValue]; NSString *post = [NSString stringWithFormat:@"&task_id=%@", myString];
它已经回答了here