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

 

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

注意:你需要下载一个开源的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];

相关文章

php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念