Skip to content

Commit

Permalink
Register cell's nib with tableview
Browse files Browse the repository at this point in the history
  • Loading branch information
gbaldera committed Jun 5, 2014
1 parent 59fdc29 commit cf71619
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
7 changes: 2 additions & 5 deletions ShoppingCartExample/Controllers/CartViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ - (void)viewDidLoad
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;

[self.tableView registerNib:[UINib nibWithNibName:@"ProductCartCell" bundle:nil] forCellReuseIdentifier:@"ProductCartCell"];

self.navigationItem.title = @"Cart";

[self loadItems];
Expand Down Expand Up @@ -94,11 +96,6 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N

ProductCartCell *cell = (ProductCartCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"ProductCartCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}

CartItem *item = [self.items objectAtIndex:[indexPath row]];

// Configure the cell...
Expand Down
7 changes: 2 additions & 5 deletions ShoppingCartExample/Controllers/ProductsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ - (void)viewDidLoad

// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;

[self.tableView registerNib:[UINib nibWithNibName:@"ProductCell" bundle:nil] forCellReuseIdentifier:@"ProductCell"];

self.navigationItem.title = @"Products";

Expand Down Expand Up @@ -70,11 +72,6 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N

ProductCell *cell = (ProductCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"ProductCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}

Product *product = [self.products objectAtIndex:[indexPath row]];

// Configure the cell...
Expand Down

0 comments on commit cf71619

Please sign in to comment.