Skip to content

Instantly share code, notes, and snippets.

@conscientiousness
Last active December 7, 2015 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save conscientiousness/91ae1e9f568c7e5c87d0 to your computer and use it in GitHub Desktop.
Save conscientiousness/91ae1e9f568c7e5c87d0 to your computer and use it in GitHub Desktop.
dequeueReusableCellWithIdentifier
//=====(1)=====
@interface ViewController ()<UITableViewDataSource,UITableViewDelegate>
{
UINib * nib;
}
@end
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
if (nib == nil) {
nib = [UINib nibWithNibName:@"GameTableViewCell" bundle:nil];
[tableView registerNib:nib forCellReuseIdentifier:@"GameTableViewCell"];
}
GameTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"GameTableViewCell"];
return cell;
}
//=====(2)=====
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
GameTableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:@"GameTableViewCell"];
if(cell==nil){
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"GameTableViewCell" owner:self options:nil];
cell = nib[0];
}
return cell;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment