NSDictionary调用writeToFile出错

来源:互联网 发布:小黄鸭淘客软件合法吗 编辑:程序博客网 时间:2024/06/05 13:32
我按照接口文档去服务器用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);
        
    }];
}

0 0