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

问题描述

一段时间以来一直在努力解决这个问题。我正在尝试在我的iphone上访问REST API,并且遇到了可以帮助我的ASIHTTP框架。所以我做了类似

  //呼叫网站的事情,所以我们可以确认用户名和密码以及网站/网站
NSURL * url = [NSURL URLWithString:urlbase];
ASIHTTPRequest * request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease];
[request setUsername:@doronkatz%40xx.com];
[request setPassword:@xxx];

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

解决方案

我建议您查看RestKit:它提供了一个出色的API,用于访问RESTful Web服务并将远程资源表示为本地对象,包括持久化他们到核心数据。开箱即用支持HTTP身份验证。


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

Where urlbase is a url to a REST site.

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?

解决方案

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的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 08:11