佚名通过本文主要向大家介绍了nsdictionary,ios nsdictionary,调用服务出错,调用接口出错,速达调用接口出错等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
问题: NSDictionary调用writeToFile出错
描述:

解决方案1:
描述:
writeToFileNSDictionary
我按照接口文档去服务器用get请求数据-(void)loadAdData
{/* "Request failed: unacceptable content-type: text/html" */
AFHTTPSessionManager *mgr = [AFHTTPSessionManager manager];
NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
parameters[@"code2"] = GMLCode2;//拼接GMLCode2这个字符串的宏定义
[mgr GET:@"http://mobads.baidu.com/cpro/ui/mads.php" parameters:parameters progress:nil success:^(NSURLSessionDataTask * _Nonnull task, NSDictionary *_Nullable responseObject) {
NSLog(@"%@",responseObject);
[responseObject writeToFile:@"/Users/chenhao/Desktop/BuDeJie/ad.plist" atomically:YES encoding:NSUTF8StringEncoding error:nil];//写入项目路径的ad.plist文件
NSDictionary *adDict = [responseObject[@"ad"] lastObject];
_item = [GMLAdItem mj_objectWithKeyValues:adDict];
CGFloat adW = GMLScreenW;
CGFloat adH = GMLScreenW / _item.w * _item.h;//按比例缩放
self.adImageView.frame = CGRectMake(0, 0, adW, adH);
[self.adImageView sd_setImageWithURL:[NSURL URLWithString:_item.w_picurl]];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
NSLog(@"%@",error);
}];
}

解决方案1:
我看了一下NSDictionary只有writetofile:automically:这个方法
并没有writeToFile:atomically:encoding:error:方法
所以提示的很正确
你问问是不是有其他人扩展了NSDictionary类,添加了这个方法.