[英]How to send the updated data using json to server in iphone?
am using web services (JSON). 正在使用Web服务(JSON)。 from json am getting data this data loading into tableview am trying to edit this data but after edit the data how to send this updated data to server. 从json获取数据,此数据正在加载到tableview中,试图编辑此数据,但是在编辑数据后如何将更新后的数据发送到服务器。 please any one help me? 请有人帮我吗?
try this will help you.. this is the post method for updating data in WS . 尝试这样做将对您有帮助。.这是在WS中更新数据的发布方法。
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);
I am assuming you have your edited data, then 我假设您已经编辑了数据,那么
Hope this helps. 希望这可以帮助。 Nothing much to it actually. 其实没什么。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.