草庐IT

afjsonrequestoperation

全部标签

ios - AFNetworking enqueRequestOperations 在调用所有 AFJSONRequestOperation 完成之前触发完成

AFHTTPClient*client=[[AFHTTPClientalloc]initWithBaseURL:[NSURLURLWithString:@"http://twitter.com"]];NSURL*url=[NSURLURLWithString:@"https://alpha-api.app.net/stream/0/posts/stream/global"];NSURLRequest*r=[NSURLRequestrequestWithURL:url];AFJSONRequestOperation*operation=[AFJSONRequestOperationJSO

ios - 在 AFJSONRequestOperation 中接受无效的 JSON?

我正在修复现有项目中的错误。问题是AFHTTPClient期望有效的JSON响应,但服务器返回一些乱码,如“”\”操作完成\””(所有引号和括号都在返回中)。这导致操作失败,并命中失败block,因为它无法解析响应。尽管如此,服务器仍返回状态代码200,并且很高兴操作已完成。我有一个像这样扩展AFHTTPClient的类(从我的.h文件中执行)@interfaceAuthClient:AFHTTPClient//blahblahblah@end在我的实现文件中,类被初始化如下:-(id)initWithBaseURL:(NSURL*)url{if(self=[superinitWith

ios - AFJSONRequestOperation : variable 'operation' is uninitialized when captured by block

我在第6行的这段代码中收到上述警告,并且userInfo在该block中也变为nil。请提出一些建议来消除此警告和userInfo问题。AFHTTPClient*httpClient=[[AFHTTPClientalloc]initWithBaseURL:[NSURLURLWithString:@"someurl"]];[httpClientregisterHTTPOperationClass:[AFJSONRequestOperationclass]];[httpClientsetParameterEncoding:AFJSONParameterEncoding];[httpClie

ios - YouTube API v3 错误 : 403 but the API key is configured and Bundle identifier is correct

我需要从youtube中提取特定channel播放列表的名称。我正在使用AFJSONRequestOperation进行调用。我不断收到错误代码“(200-299)中的预期状态代码,得到403”。我已经在谷歌注册,我的包标识符是正确的。这是我的代码(我划掉了我的apiKEY的最后十个字符):NSURL*url=[[NSURLalloc]initWithString:@"https://www.googleapis.com/youtube/v3/playlists?part=snippet&channelId=UCHvTZKuI5zQnxmbgSE-CFug&maxResults=50&

ios - 如何将 AFNetworking AFJSONRequestOperation 包装到单独的数据管理器类中

我刚开始在iOS中使用block,我认为这可能是我问题的症结所在。我只想构建一个简单的静态DataManager类,它的唯一工作就是从我的Restful服务中获取数据。我会从我所有的各种UIViewControllers(或collectionview/tableController)中调用它在我的课上我有一个看起来像这样的函数+(NSArray*)SearchByKeyword:(NSString*)keyword{__blockNSArray*searchResults=[[NSArrayalloc]init];NSString*baseURL=@"http://someURL.c

objective-c - AFJSONRequestOperation 失败,因为 web 服务返回内容类型为 text/html 的 JSON

我正在尝试更新我的应用程序以使用AFNetworking,但我需要使用的网络服务将JSON作为文本/html返回,这在我尝试使用AFJSONRequestOperation时中断了:Expectedcontenttype{("text/json","application/json","text/javascript")},gottext/html有没有办法在AFNetworking中覆盖它以便我可以接受文本/html? 最佳答案 是的,AFNetworking支持添加可接受的内容类型。在AFHTTPClient子类的init方法中

ios - AFNetworking 版本 2 内容类型错误

我正在尝试制作一个将与特定JIRA服务器交互的iphone应用程序。我有以下代码登录:NSURL*url=[[NSURLalloc]initWithString:@"https://mycompany.atlassian.net/rest/auth/latest/session/"];NSMutableURLRequest*request=[NSMutableURLRequestrequestWithURL:url];[requestsetHTTPMethod:@"POST"];NSString*postString=[NSStringstringWithFormat:@"{\"use

iphone - AFNetworking 预期内容类型错误

我在失败block中获取json字符串NSURL*url=[[NSURLalloc]initWithString:@"http://www.vinipost.com/Services/Update/UpdateService.asmx/GetPropSubType?"];NSURLRequest*request=[[NSURLRequestalloc]initWithURL:url];[AFJSONRequestOperationaddAcceptableContentTypes:[NSSetsetWithObject:@"text/html"]];AFJSONRequestOpera

ios - AFNetworking AFHTTPClient AFJSONRequestOperation 不使用 JSON 操作

我关注了这个截屏视频...http://nsscreencast.com/episodes/6-afnetworking我的单例AFHTTPClient代码是...+(MyClient*)sharedInstance{staticdispatch_once_tonce;staticMyClient*myClient;dispatch_once(&once,^{myClient=[[MyClientalloc]initWithBaseURL:[NSURLURLWithString:MyBaseURL]];});returnmyClient;}-(id)initWithBaseURL:(N

iphone - 使用 AFJSONRequestOperation 返回 JSON

我已经实现了AFNetworking框架,但是我试图找出一种在单独的类中使用AFJSONRequestOperation函数并从我的个人ViewController调用它的方法。我所做的是创建一个类方法,它采用字典中的参数和web服务url。我希望这能够从成功block返回JSON数组和Http代码,但这不起作用。如果我将公共(public)函数更改为具有返回类型并在方法末尾返回一个值,它会在成功block完成之前返回。有什么建议吗?+(void)RequestJSON:(NSDictionary*)params:(NSString*)webServicePath{NSURL*url=
12