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

前端之家收集整理的这篇文章主要介绍了AFNetworking获取服务端plist文件,XML文件前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
  1.  

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

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

请速度收藏

  1. NSString *urlString=@"http://127.0.0.1:8080/app/test.plist";
  2. NSURL *url = [NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
  3. NSURLRequest *request = [NSURLRequest requestWithURL:url];
  4. [AFPropertyListRequestOperation addAcceptableContentTypes:[NSSet setWithObject:@"application/xml"]];
  5. AFPropertyListRequestOperation *operation = [AFPropertyListRequestOperation propertyListRequestOperationWithRequest:request success:^(NSURLRequest *request,NSHTTPURLResponse *response,id propertyList) {
  6. // NSLog(@" - - - - - - - - - - %@ - - —!__!_!_!_!_",[propertyList class]);
  7. [arrList removeAllObjects];
  8. if ([propertyList isKindOfClass:[NSArray class]]) {
  9. NSArray *arr=(NSArray *)propertyList;
  10. [arrList addObjectsFromArray:arr];
  11. [table reloadData];
  12. }
  13. [table headerEndRefreshing];
  14. }failure:^(NSURLRequest *request,NSError *error,id propertyList) {
  15. NSLog(@"!!!!! %@",error);
  16. [table headerEndRefreshing];
  17. }];
  18. [operation start];

猜你在找的XML相关文章