优化代码结构笔记
2016-02-23 15:17
344 查看
静态的DataSource - 使用Plist来设置静态资源。
NSString *shopListPath = [[NSBundle mainBundle]pathForResource:@"shop" ofType:@"plist"]; self.shops = [[NSArray alloc]initWithContentsOfFile:shopListPath];
#pragma mark - TableView DataSource - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { NSArray *sectionArray = self.shops[section]; return sectionArray?sectionArray.count:0; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return self.shops?self.shops.count:0; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellID"]; NSArray *sectionArray = self.shops[indexPath.section]; NSDictionary *shopDict = sectionArray[indexPath.row]; cell.textLabel.text = shopDict[@"title"]; cell.detailTextLabel.text = shopDict[@"content"]; return cell; }
相关文章推荐
- MySQL 优化
- Google排名优化的几个影响因素
- DB2优化(简易版)
- Mysql limit 优化,百万至千万级快速分页 复合索引的引用并应用于轻量级框架
- C#中尾递归的使用、优化及编译器优化
- 对优化Ruby on Rails性能的一些办法的探究
- 优化Ruby脚本效率实例分享
- Asp编码优化技巧
- 如何监测和优化OLAP数据库
- mysql -参数thread_cache_size优化方法 小结
- 深入学习SQL Server聚合函数算法优化技巧
- MySQL常见的底层优化操作教程及相关建议
- 详解mysql的limit经典用法及优化实例
- 数据库学习建议之提高数据库速度的十条建议
- oracle数据库sql的优化总结
- SQL语句优化提高数据库性能
- SQL优化经验总结
- SQL优化技巧指南
- SQL Server优化50法汇总
- C++快速排序的分析与优化详解