下拉刷新需要清空,
if (worksPageIndex == 1) {//第一页的时候
[worksInfoArray removeAllObjects];
}
这个有点重复了,为什么要用 tempArr呢,是害怕出错么,是安慰么,
NSMutableArray *tempArr = [[NSMutableArrayalloc] init];
if (!tempArr) {
tempArr = [[NSMutableArray alloc] init];
}
[tempArr removeAllObjects];
[tempArr addObjectsFromArray:[WorksInfo worksArrayWithDic:responseObject]];
if (!worksInfoArray) {
worksInfoArray = [[NSMutableArray alloc] init];
}
[worksInfoArray addObjectsFromArray:tempArr];
变成:
if (!worksInfoArray) {
worksInfoArray = [[NSMutableArray alloc] init];
}
[worksInfoArray addObjectsFromArray:[WorksInfo worksArrayWithDic:responseObject]];
ps:第一次进入 加载缓存,点击 segmentbutton 时候是不加缓存的,并且 只缓存第一页的 缓存,第二页是没有必要加载的,