如何使用json将更新的数据发送到iphone中的服务器?

如何使用json将更新的数据发送到iphone中的服务器?,iphone,objective-c,ios,ipad,Iphone,Objective C,Ios,Ipad,我正在使用web服务(JSON)。我从json获取数据,将此数据加载到tableview,我试图编辑此数据,但在编辑数据后,如何将此更新的数据发送到服务器。 有人帮我吗 我假设您有您编辑的数据,然后 形成你的json。有几个图书馆可以帮助你 了解服务器的主机名 知道要在服务器上使用哪个API 然后将此json作为POST传递(GET也可以,但POST是首选) 在服务器上处理接收到的json 希望这有帮助。实际上没什么大不了的。我假设你有你编辑过的数据,那么 形成你的json。有几个图书馆可以帮助

我正在使用web服务(JSON)。我从json获取数据,将此数据加载到tableview,我试图编辑此数据,但在编辑数据后,如何将此更新的数据发送到服务器。
有人帮我吗

我假设您有您编辑的数据,然后

  • 形成你的json。有几个图书馆可以帮助你
  • 了解服务器的主机名
  • 知道要在服务器上使用哪个API
  • 然后将此json作为POST传递(GET也可以,但POST是首选)
  • 在服务器上处理接收到的json

  • 希望这有帮助。实际上没什么大不了的。

    我假设你有你编辑过的数据,那么

  • 形成你的json。有几个图书馆可以帮助你
  • 了解服务器的主机名
  • 知道要在服务器上使用哪个API
  • 然后将此json作为POST传递(GET也可以,但POST是首选)
  • 在服务器上处理接收到的json

  • 希望这有帮助。实际上没什么大不了的。

    试试看,这会对你有帮助。。这是更新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);
    

    试试这个会对你有帮助的。。这是更新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);