AFNetworking

2018-11-13  本文已影响0人  自知则知

AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];

    [manager GET:URL parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {

    }success:^(NSURLSessionDataTask*_Nonnulltask,id  _NullableresponseObject) {

        NSLog(@"%@",responseObject);

[NewsModel mj_setupObjectClassInArray:^NSDictionary *{

            return@{

                @"list":@"ListModel",

                @"list":@"LIstModelTWO",

                @"data":@"dataModel"

            };

        }];

        self.model= [Model mj_objectWithKeyValues:responseObject];

        NSLog(@"asdf");

        [self.tableViewreloadData];

    }failure:^(NSURLSessionDataTask*_Nullabletask,NSError*_Nonnullerror) {

        NSLog(@"%@",error);

    }];

Model"::::  .h

先数组

@interfaceNewsModel :NSObject

@property (nonatomic , copy) NSArray *list; //数组一

@end

@interfaceListModel :NSObject

@property (nonatomic , copy) NSString *moduleType;

@property (nonatomic , copy) NSArray *list;  //数组二

@end

cell::

//    ListModel *listModel = self.newsModel.list[0];

//    NSDictionary *dic = listModel.list[0];

//    NSArray *arr = dic[@"data"];

//    NSDictionary *dataDic = arr[indexPath.row];

//

//    cell.imageView.image = [UIImage imageWithData:[self ImageWithString:dataDic[@"cover"]]];

//    ListModel *listModel = self.newsModel.list[0];

//  listModel.moduleType

-(NSData*)ImageWithString:(NSString*)string{

    NSURL*url = [NSURLURLWithString:string];

    return [NSData dataWithContentsOfURL:url];

}

上一篇下一篇

猜你喜欢

热点阅读