美文网首页
DOM多分区

DOM多分区

作者: 法库德 | 来源:发表于2017-10-18 08:33 被阅读0次

#import "GDataXMLNode.h"

#import "Model.h"

{

NSMutableDictionary *dic;

UITableView *tab;

}

# define MAC @"http://127.0.0.1/LOL.xml"

//

NSURL *url=[NSURL URLWithString:MAC];

NSURLSession * see=[NSURLSession sharedSession];

NSURLSessionDataTask *tas=[see dataTaskWithURL:url completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {

//创建对象

GDataXMLDocument *the=[[GDataXMLDocument alloc]initWithData:data options:0 error:nil];

//获取跟标签

GDataXMLElement *rootel=[the rootElement];

//初始化字典

dic=[[NSMutableDictionary alloc]init];

for (GDataXMLElement *sor in [rootel elementsForName:@"a"])

{

NSString *key=[[sor attributeForName:@"king"]stringValue];

NSMutableArray *arr=[[NSMutableArray alloc]init];

//给数组添加数据

for (GDataXMLElement *hfenelem in [sor elementsForName:@"fen"])

{

Model *mo=[[Model alloc]init];

mo.name=[[[hfenelem elementsForName:@"name"]firstObject]stringValue];

mo.age=[[[hfenelem elementsForName:@"age"]firstObject]stringValue];

[arr addObject:mo];

}

//给字典赋值

[dic setObject:arr forKey:key];

}

//回到主线程刷新表格

dispatch_async(dispatch_get_main_queue(), ^{

//刷新表格

[tab reloadData];

});

}];

[tas resume];

tab=[[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStyleGrouped];

tab.delegate=self;

tab.dataSource=self;

[self.view addSubview:tab];

}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

{

return dic.count;

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;

{

NSString *key=[dic.allKeys objectAtIndex:section];

return [[dic objectForKey:key]count];

}

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

static NSString *str=@"cell";

UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:str];

if (cell==nil)

{

cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:str];

}

NSString *key=[dic.allKeys objectAtIndex:indexPath.section];

cell.textLabel.text=[[[dic objectForKey:key]objectAtIndex:indexPath.row]name];

cell.detailTextLabel.text=[[[dic objectForKey:key]objectAtIndex:indexPath.row]age];

return cell;

}

-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section

{

return [dic.allKeys objectAtIndex:section];

}

model类

@property(nonatomic,strong)NSString *name,*age;

相关文章

  • DOM多分区

    #import "GDataXMLNode.h" #import "Model.h" { NSMutableDic...

  • 操作系统-存储管理

    为什么内存要分区?分区有哪些类型? 内存分区是为了方便地支持多程序运行。分区管理分为固定分区和可变分区,固定分区是...

  • Virtual DOM

    Virtual DOM 虚拟 DOM 普通 JS 对象描述 DOM 对象 DOM 对象:成员多,成本高 虚拟 DO...

  • SPARK[RDD之partitions]

    RDD是容错、并行的数据结构,具备分区的属性,这个分区可以是单机上分区也可以是多机上的分区,对于RDD分区的数量涉...

  • Hive01

    Hive 启动 Hive 启动方式 建表语法【单分区】示例: 加载【单分区】数据示例: 【多分区】示例: 加载【多...

  • Kafka的分区数和消费者个数

    Kafka的分区数是不是越多越好? 分区多的优点 kafka使用分区将topic的消息打散到多个分区分布保存在不同...

  • ios GDataXML(DOM)解析分区表格

    GDataXML是Google开发的一个XML解析库,轻便,特点使用非常简单,支持XPath。 前言:GDataX...

  • Oc GDataXML(DOM)解析分区表格

    首先导入第三方GDataXML 手写xml文件 Model类Hero.h 控制器类ViewController.m

  • Vue源码阅读之diff算法

    虚拟dom 虚拟dom解决了什么问题 首先是正常的一个真实dom拥有的属性非常多,还拥有很多dom操作的方法 其次...

  • 操作系统应用

    引导 多操作系统引导顺序 磁盘管理 磁盘分区主分区逻辑分区逻辑驱动器 磁盘整理 设备管理 查看设备驱动是否正常工作...

网友评论

      本文标题:DOM多分区

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