iphone中的REST风格的webservice
我还建议首先在Stackoverflow上搜索可能的答案。但是使用REST基础web服务的一个具体答案。我强烈建议ASIHTTPRequest。他们有一个非常简单的方法来从服务中检索数据。我在很多需要访问web服务的应用程序中使用了代码。
NSURL *url = [NSURL URLWithString:@"http://allseeing-i.com"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request startSynchronous];
NSError *error = [request error];
if (!error) {
NSString *response = [request responseString];
}
是这种方法足以接收来自服务的数据? 我应该导入哪些库文件以使用ASIHTTPRequest? – carthee 2010-08-12 10:31:43
是的,'response'变量将包含服务返回的数据。访问http://allseeing-i.com/ASIHTTPRequest/Setup-instructions并下载他们的文件,然后按照说明复制它们。 – christophercotton 2010-08-12 14:56:24
你好,我是新来的ios,所以任何人都有工作的例子来调用和解析restfull webservice – user1374 2014-02-24 05:51:47
它已被问了很多次。在发布问题之前在stackoverflow上搜索。请参阅:http://stackoverflow.com/questions/3110817/iphone-dealing-with-xml-vs-soap-vs-json-vs-restful或http://stackoverflow.com/questions/1908560/developing-restful-网站和iPhone和可能其他智能手机应用等等... http://stackoverflow.com/search?q=restful+webservice+iphone – lukya 2010-08-11 09:55:49