In iOS5, using ARC and prototype cells for tableView on storyboard, can I replace the code below:
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier];
}
// Configure the cell...
return cell;
With this simple code?:
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:@"Cell"];
return cell;
I saw this on this link:
http://www.raywenderlich.com/5138/beginning-storyboards-in-ios-5-part-1
Thank's in advance!
This problem is happening because you aren't creating the
MenuViewController
from the storyboard. You are creating it like this:That instance of
MenuViewController
isn't connected to the storyboard, so it doesn't know about the prototype cells in the storyboard.You need to go into your storyboard and set the identifier of the
MenuViewController
there to something likemenuViewController
. Then you can create an instance like this:My solution was finally like this:
Because form iOS 5.0 onwards the first line of code will never produce a nil value, and I saw no other way to specify the style I wanted. Or, I could have Added an instance of Table View Controller from the library, and then I could edit the style in the prototype cell.