我正在创建一个php文件并上传到mywebsite.Now如何将xcode textfield中的值插入json.please任何人都知道帮助我
答案 0 :(得分:3)
你可以这样做:
NSDictionary *jsonDict1=[NSDictionary dictionaryWithObjectsAndKeys:textfield.text,@"filename",nil];
NSString *jsonString1=[jsonDict1 JSONRepresentation];
NSString *post1 = [NSString stringWithFormat:@"json=%@",jsonString1];
答案 1 :(得分: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]];