我正在创建一个 php 文件并上传到 mywebsite。现在如何将值从 xcode 文本字段插入到 json。请任何知道的人帮助我
问问题
435 次
2 回答
3
你可以这样做:
NSDictionary *jsonDict1=[NSDictionary dictionaryWithObjectsAndKeys:textfield.text,@"filename",nil];
NSString *jsonString1=[jsonDict1 JSONRepresentation];
NSString *post1 = [NSString stringWithFormat:@"json=%@",jsonString1];
于 2013-01-03T07:36:39.547 回答
0
const char *bytes = "mydata=Hello%20World";
NSString * str = [NSString stringWithFormat:@"<?xml version=\"1.0\"?>\n<mydata>%@</mydata>", data];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:[str dataUsingEncoding:NSUTF8StringEncoding]];
于 2013-01-03T07:38:22.540 回答