Objective-C:在 iPhone 上访问 REST API 的最佳方式 [英] Objective-C: Best way to access REST API on your iphone

查看:50
本文介绍了Objective-C:在 iPhone 上访问 REST API 的最佳方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为此纠结了一段时间.我试图在我的 iphone 上访问 REST api 并遇到了可以帮助我的 ASIHTTP 框架.所以我做了类似的事情

been wrestling with this for some time. I am trying to access a REST api on my iphone and came across the ASIHTTP framework that would assist me. So i did something like

//call sites, so we can confirm username and password and site/sites
NSURL *url = [NSURL URLWithString: urlbase];
ASIHTTPRequest *request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease];
[request setUsername:@"doronkatz%40xx.com" ];
[request setPassword:@"xxx"];

其中 urlbase 是 REST 站点的 url.

Where urlbase is a url to a REST site.

现在,一位开发人员告诉我这个框架可能存在问题或错误,并且它没有正确传递标头.是否有其他方法可以通过身份验证测试或访问网络 REST 位置?

Now, a developer has told me there might be an issue or bug with this framework, and its not passing headers correctly. Is there another way of testing or accessing with authentication a network REST location?

推荐答案

我建议您查看 RestKit:http://restkit.org/ 它提供了一个优秀的 API 来访问 RESTful Web 服务并将远程资源表示为本地对象,包括将它们持久化到 Core Data.支持开箱即用的 HTTP 身份验证.

I would recommend checking out RestKit: http://restkit.org/ It provides an excellent API for accessing RESTful web services and representing the remote resources as local objects, including persisting them to Core Data. HTTP authentication is supported out of the box.

这篇关于Objective-C:在 iPhone 上访问 REST API 的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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