- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [self.array count]+1;
}
//加载数据的方法
-(void)loadMore;
{
//获得plist文件的路径
NSString *path = [[NSBundle mainBundle] pathForResource:@\”add\”
ofType:@\”plist\”];
//将plist文件中的数据存储到可变数组中
NSMutableArray *more = [[NSMutableArray alloc] initWithContentsOfFile:path];
[self performSelectorOnMainThread:@selector(appendTableWith withObject:more waitUntilDone:NO];
[more release];
}
//添加数据到列表
-(void) appendTableWith:(NSMutableArray *)data;
{
for (int i=0;i<[data count];i++) {
//将要增加的数据添加到可变数组中
[self.array addObject:[data objectAtIndex:i]];
}
//设置要插入行数目
NSMutableArray *insertIndexPaths = [NSMutableArray arrayWithCapacity:10];
for (int ind = 0; ind < [data count]; ind++) {
//取得要添加数据所要加入cell的行号
NSIndexPath *newPath = [NSIndexPath indexPathForRow:[self.array indexOfObject:[data objectAtIndex:ind]] inSection:0];
[insertIndexPaths addObject:newPath];
}
//将新加入的数据刷到已经存在的数据之后cell中
[self.tableView insertRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationFade];
}