加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

AFNetworking获取服务端plist文件,XML文件

发布时间:2020-12-16 06:16:11 所属栏目:百科 来源:网络整理
导读:本人向来不喜欢啰嗦,只喜欢简单粗暴,上代码!!! 注意:你需要下载一个开源的AFNetworking包,版本很多,本人提供一个网盘下载地址: http://pan.baidu.com/s/1jGzmyea 请速度收藏 NSString *urlString=@"http://127.0.0.1:8080/app/test.plist"; NSURL *u
 

本人向来不喜欢啰嗦,只喜欢简单粗暴,上代码!!!

注意:你需要下载一个开源的AFNetworking包,版本很多,本人提供一个网盘下载地址: http://pan.baidu.com/s/1jGzmyea

请速度收藏

 NSString *urlString=@"http://127.0.0.1:8080/app/test.plist";
    NSURL *url = [NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [AFPropertyListRequestOperation addAcceptableContentTypes:[NSSet setWithObject:@"application/xml"]];
    AFPropertyListRequestOperation *operation = [AFPropertyListRequestOperation propertyListRequestOperationWithRequest:request success:^(NSURLRequest *request,NSHTTPURLResponse *response,id propertyList) {
//        NSLog(@" - - - - - - - - - - %@ - - —!__!_!_!_!_",[propertyList class]);
        
        [arrList removeAllObjects];
        if ([propertyList isKindOfClass:[NSArray class]]) {
            NSArray *arr=(NSArray *)propertyList;
            
            
            [arrList addObjectsFromArray:arr];
            
            [table reloadData];
            
            
            
            
        }
        
        
        [table headerEndRefreshing];
        
    }failure:^(NSURLRequest *request,NSError *error,id propertyList) {
        NSLog(@"!!!!!     %@",error);
        
        [table headerEndRefreshing];
    }];
    
    [operation start];

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读