有没有人用过yahoo汇率api,AFNetworking解析错误,在线求助!!!

shelly 2014-08-20 03:31:34
代码:
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/plain", nil];
[manager GET:@"http://download.finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s=USDUSD=x+USDCNY=x+USDHKD=x+USDJPY=x+USDTHB=x+USDEUR=x+USDGBP=x> parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject)
{
NSLog(@"JSON: %@", responseObject);
}
failure:^(AFHTTPRequestOperation *operation, NSError *error)
{
NSLog(@"failed:%@",error);
}];

报错:Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (JSON text did not start with array or object and option to allow fragments not set.) UserInfo=0x8d8e510 {NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}
...全文
154 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
zioc2014 2014-08-20
  • 打赏
  • 举报
回复
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; manager.responseSerializer = [CustomResponseSerializer new]; [manager GET:@"http://download.finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s=USDUSD=x+USDCNY=x+USDHKD=x+USDJPY=x+USDTHB=x+USDEUR=x+USDGBP=x" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"success"); } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"failed"); }]; @interface CustomResponseSerializer : AFHTTPResponseSerializer @end @implementation CustomResponseSerializer -(id)responseObjectForResponse:(NSURLResponse *)response data:(NSData *)data error:(NSError *__autoreleasing *)error{ // 返回nil为失败;返回有效的对象,即成功 return @""; } @end

29,030

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧