美文网首页
解析 + 网络请求

解析 + 网络请求

作者: 0bf43b438419 | 来源:发表于2019-04-07 09:35 被阅读0次

#import "YCViewController.h"
#import "YCmodel.h"
#import "YCTableViewCell.h"
#import "MBProgressHUD.h"
#import "MJRefresh.h"
#import "AFNetworking.h"
#import "MJExtension.h"
#import "UIImageView+WebCache.h"
#import "YanchuangViewController.h"
@interface YCViewController ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,strong)UITableView * tab;
//可变数组
@property(nonatomic,strong)NSMutableArray * aray;
@end

@implementation YCViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.aray=[[NSMutableArray alloc]init];
   
    self.tab=[[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStylePlain];
   
    self.tab.delegate=self;
    self.tab.dataSource=self;
   
    [self.tab registerNib:[UINib nibWithNibName:@"LXTableViewCell" bundle:nil] forCellReuseIdentifier:@"cell"];
    [self.view addSubview:self.tab];
    [self AFNet];
   
}

-(void)AFNet{
   
    AFHTTPSessionManager * manager   = [AFHTTPSessionManager manager];
    [manager GET:@"http://c.m.163.com/nc/article/list/T1348648517839/0-20.html" parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSLog(@"%@",responseObject);
        NSArray *aray = responseObject[@"T1348648517839"];
        for(NSDictionary  * dic in aray){
            YCmodel * model  =[[YCmodel alloc ]init];
            [model setValuesForKeysWithDictionary:dic];
            [self.aray addObject:model];
           
        }
        //        dispatch_async(dispatch_get_main_queue(), ^{
        [self.tab reloadData];
       
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
       
    }];
   
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.aray.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
   
    YCTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    [cell  loadDataFromModel:self.aray[indexPath.row]];
   
    return cell;
   
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
   
    YanchuangViewController * first =[ YanchuangViewController new];
    YCmodel  * model = self.aray[indexPath.row];
    first.urstring = model.url;
    [self.navigationController pushViewController:first animated:YES];
   
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 150;
}

相关文章

  • 详细解析几个和网络请求有关的类

    详细解析几个和网络请求有关的类 (一) —— NSURLSession详细解析几个和网络请求有关的类(二) —— ...

  • iOS之网络简解篇.

    网络 HTTP请求 GET请求 POST请求 数据解析 JSONNSJSONSerialization XMLSA...

  • Android 通用流行框架大全

    *** 缓存*** *** 图片加载*** *** 图片处理*** *** 网络请求*** *** 网络解析***...

  • AFNetWorking使用

    GET请求 POST 下载 上传 JSON解析 xml解析 检测网络状态

  • retrofit 由浅入深(三)源码解析

    源码理解主要从这几个方面 解析网络请求接口的注解配置网络请求参数 动态代理 生成 网络请求对象 网络请求适配器 将...

  • 五、Groovy语法(五)json、xml解析

    Groovy数据解析 一、json解析 请求网络数据并解析 二、xml解析 groovy解析xml数据 groov...

  • 解析 + 网络请求

    #import "YCViewController.h"#import "YCmodel.h"#import "Y...

  • AFNetworking

    http网络库是集XML解析,Json解析,网络图片下载,plist解析,数据流请求操作,上传,下载,缓存等网络众...

  • 网络

    NSURLConnection NSURLSession 普通网络请求 JSON数据解析 JSON序列化 数据解析...

  • Retrofit 基础原理之总结

    简述: 1.网络请求: 2.网络请求流程梳理: 上述2角色解析 3.网络请求适配器: 4.网络请求执行器: 5.数...

网友评论

      本文标题:解析 + 网络请求

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