1
正在使用Web服务(JSON)。从json获取数据这个数据加载到tableview我试图编辑这些数据,但编辑后数据如何发送更新的数据到服务器。 请任何人帮助我?如何使用json发送更新的数据到iphone中的服务器?
正在使用Web服务(JSON)。从json获取数据这个数据加载到tableview我试图编辑这些数据,但编辑后数据如何发送更新的数据到服务器。 请任何人帮助我?如何使用json发送更新的数据到iphone中的服务器?
我假设你有你编辑的数据,然后
希望这会有所帮助。实际上没什么大不了的。
试试这个会帮助你..这是在WS中更新数据的post方法。
NSString *post =[NSString stringWithFormat:@"uid=%@&firstname=%@&lastname=%@&phone=%@&bday=%@&about_me=%@&image=%@&image_code=%@&contact_number=%@",LoginID,fname,lname,cn,bday,abtme,strimage11,c11,cn];
NSData *postData = [post dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:[NSURL URLWithString:@"YOUR LINK"]];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setValue:@"application/x-www-form-urlencoded charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
NSError *error;
NSURLResponse *response;
NSData *uData=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSString *data=[[NSString alloc]initWithData:uData encoding:NSUTF8StringEncoding];
//
NSMutableDictionary *temp = [data JSONValue];
//
NSLog(@"%@",temp);