从ipad向服务器发送数据 [英] sending data to a server from ipad

查看:79
本文介绍了从ipad向服务器发送数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即时开发一个用于医院管理的i​​pad应用程序,用户界面中填写了信息,点击一个按钮,数据将被转移到外部数据库(稍后可以查看)...需要什么步骤

i m developing an ipad app for hospital management were information is filled in the user interface and on the click of a button the data is to be transfered to an external database(which later be viewed)...what are the steps required

推荐答案

你需要建立一个web服务(如Saurabh所说),例如使用mySQL连接的PHP文件就可以了。

You need to set up a webservice (like Saurabh said), for instance a PHP file using an mySQL connection would do fine.

要将数据(不安全)发布到服务,您可以使用以下内容:

To post the data (unsecured) to the service you can dome something like this:

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];

阅读NSURLConnection文档

这篇关于从ipad向服务器发送数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆