2018 4-4

作者: 5e6b9ff4ae58 | 来源:发表于2018-12-20 20:35 被阅读0次

#import "ViewController.h" #import "Model.h" #import "AFNetworking.h" #import "MJExtension.h" @interface ViewController ()<UITableViewDelegate,UITableViewDataSource> @property(nonatomic,strong)NSArray *arr; @property(nonatomic,strong)UITableView *tbv; @end @implementation ViewController - (void)viewDidLoad {     [super viewDidLoad];               [self createNav];          [self.view addSubview:self.tbv];      } -(void)createNav{               //2.发送GET请求     /*      第一个参数:请求路径(不包含参数).NSString      第二个参数:字典(发送给服务器的数据~参数)      第三个参数:progress 进度回调      第四个参数:success 成功回调      task:请求任务      responseObject:响应体信息(JSON--->OC对象)      第五个参数:failure 失败回调      error:错误信息      响应头:task.response      */          AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];          //参数     NSMutableDictionary *params = [NSMutableDictionary dictionary];     params[@"method"] = @"app.news.getarticlelist";     params[@"class_id"] = @"3";     params[@"_debug"] = @"Y";          [manager POST:@"http://test.bit.api.meeboo.cc" parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {                  [DataModel mj_setupObjectClassInArray:^NSDictionary *{             return @{                      @"list":@"ImgModel"                      };         }];                  Model *model = [Model mj_objectWithKeyValues:responseObject];                  self.arr = model.data.list;                  [self.tbv reloadData];                           NSLog(@"%@---%@",[responseObject class],responseObject);                                } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {         NSLog(@"请求失败--%@",error);     }];           } -(UITableView *)tbv{     if (!_tbv) {         _tbv = [[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStylePlain];     }          _tbv.dataSource = self;     _tbv.delegate = self;          return _tbv;      } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{     return _arr.count; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];          if (!cell) {         cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];     }      //    cell.textLabel.text = [self.arr[indexPath.row] objectForKey:@"title"];     ImgModel *model = self.arr[indexPath.row];     cell.detailTextLabel.text = model.title;     return cell;      }

@interfaceImgModel :NSObject

@property(nonatomic,strong)NSDate *create_time;

@property(nonatomic,copy)NSString *id;

@property(nonatomic,copy)NSString *title;

@end

@interfaceDataModel :NSObject

@property(nonatomic,assign) int page;

@property(nonatomic,assign) int pages;

@property(nonatomic,copy) NSArray *list;

@end

@interface Model : NSObject

@property(nonatomic,assign) int code;

@property(nonatomic,strong) DataModel *data;

@end



@implementation ImgModel

@end

@implementation DataModel

@end

@implementation Model

相关文章

  • 2018 4-4

    #import "ViewController.h"#import "Model.h"#import "AFNet...

  • WEEK4 4-4 The Value of Teamwork

    DATE 2016/01/28COURSE 4-4 The Value of TeamworkNOTES OU...

  • 4-4

    纵然时过境迁,我不会选择重新在一起,我也不能一个人活在过去!

  • 4-4

    关于预测,我只能说,是聪明人,为什么这么说呢?人类社会存在的落差感就是预测,很多人为什么是被人叫做穷人,被人叫做底...

  • 4-4

    在之前的两堂课中 我们讲到多准则决策以及空间决策接下来我们将讲到涉及概率的在不确定性条件下的决策 为此我首先想花一...

  • 4-4

    vuex 理解 6.1.1. vuex 是什么 简单来说: 对 vue 应用中多个组件的共享状态进行集中式的管理(...

  • 4-4

    一阵齐鸣,拉我到了现实。 一场疫情多少人心惊胆战, 多少仁人志士奔赴前线, 多少父母担心在外的孩子, 多少儿女渴望...

  • mybatis笔记

    mybatis http://www.imooc.com/learn/587 可以参照这个视频的4-3,4-4,4...

  • CoreData 4-4 数据模型和模型对象【转自 https:

    CoreData 4-4 数据模型和模型对象【转自 https://objccn.io/issue-4-4/】 ...

  • 2016—4-4

    宋给我打电话,解释我们为什么不能在一起,他说:“我觉得我们在一起不合适,我看得出你喜欢我,其实我也喜欢你,可是我感...

网友评论

      本文标题:2018 4-4

      本文链接:https://www.haomeiwen.com/subject/atvukqtx.html