#pragmamark返回每行的單元格
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{//NSIndexPath是一個(gè)對(duì)象,記錄了組和行信息NSLog(@"生成單元格(組:%i,行%i)",indexPath.section,indexPath.row);
KCContactGroup *group=_contacts[indexPath.section];
KCContact *contact=group.contacts[indexPath.row];//由于此方法調(diào)用十分頻繁,cell的標(biāo)示聲明成靜態(tài)變量有利于性能優(yōu)化staticNSString *cellIdentifier=@"UITableViewCellIdentifierKey1";//首先根據(jù)標(biāo)識(shí)去緩存池取UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellIdentifier];//如果緩存池沒(méi)有到則重新創(chuàng)建并放到緩存池中if(!cell){
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellIdentifier];
}
cell.textLabel.text=[contact getName];
cell.detailTextLabel.text=contact.phoneNumber;
NSLog(@"cell:%@",cell);returncell;
}