获取本地资源

导航栏按钮颜色
[self.navigationItem.leftBarButtonItem setTintColor:[UIColor whiteColor]];

首先 定义数组属性
@property (nonatomic , strong)NSMutableArray *array;

创建 Model 类 继承 NSobject
定义属性
@property (nonatomic , strong)NSString *title;
@property (nonatomic , strong)NSString *time;
@property (nonatomic , strong)NSString *tu;
@property (nonatomic , strong)NSString *datatitle;

-(void)addnet{

//GET 请求
//创建网络路径
NSURL *url = [NSURL URLWithString:@"http://127.0.0.1/Property.json"];
//创建网络请求
NSURLRequest *request = [NSURLRequest requestWithURL:url];
//获取会话对象
NSURLSession *session = [NSURLSession sharedSession];
//根据会话对象  创建一个task任务
NSURLSessionDataTask *sessionTask = [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
    
    //对服务器返回的数据进行处理
    if (error) {
        NSLog(@"请求数据失败");
    }else{
        //NSLog(@"%@",[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];
        NSArray *arr = dict[@"restuts"];
        
        for (NSDictionary *dic in arr) {
            
            Model *mo = [[Model alloc]init];
            
            [mo setValuesForKeysWithDictionary:dic];
            
            [self->_array addObject:mo];
            
            dispatch_async(dispatch_get_main_queue(), ^{
               
                [self->_tbV reloadData];
                
            });
            
        }
        
    }
    
    
    
}];
//执行任务
[sessionTask resume];

}

.m中
Model *model = self.array[indexPath.row];
cell.imageView.image = [UIImage imageNamed:model.tu];
cell.textLabel.text =model.title;
cell.detailTextLabel.text = model.datatitle;
cell.detailTextLabel.textColor = [UIColor lightGrayColor];

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值