我正在开发一个用于医院管理的ipad应用程序,其中信息填写在用户界面中,单击一个按钮,数据将被传输到外部数据库(稍后可查看)...what是所需的步骤。
发布于 2011-04-07 20:37:02
你需要设置一个网络服务(就像Saurabh说的那样),例如,一个使用mySQL连接的PHP文件就可以了。
要将数据(不受保护的)发布到该服务,您可以使用如下所示的内容:
NSString *post = @"key1=val1&key2=val2";
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:[NSURL URLWithString:@"http://www.someurl.com"]];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content- Type"];
[request setHTTPBody:postData];
NSURLConnection *conn=[[NSURLConnection alloc] initWithRequest:request delegate:self];Read the NSURLConnection documentation
发布于 2011-04-07 20:18:07
您需要在服务器上创建see服务以在数据库中添加数据请参阅此问题的答案以了解如何发送数据
https://stackoverflow.com/questions/5580803
复制相似问题