0
votes

In WWDC 2011 video 309 on Storyboards. They demonstrate using a custom UITableViewCell that has been subclassed. In the cellForRowAtIndexPath they setup the cell by getting a NSManagedObject and setting a property of the custom cell to the managed object. The presenter says the custom table cell will set the UILabels using the managed object.

They never show the code for the custom tableview cell. My question is what method would you override in UITableViewCell to update the cell?

And yes I know you normally do this in cellForRowAtIndexPath by using either tags or importing the header for the tableViewCell and accessing it's properties.

2

2 Answers

0
votes

Usually you create your own method to update cell data, e.g.


@interface MyCell : UITableViewCell

@property (nonatomic, retain, readwrite) IBOutlet UILabel* label;

- (void)setData:(NSString*)data;

@end

@implementation

@synthesize label = label_;

- (void)setData:(NSString*)data {
    self.label.text = data;
}

@end

Of course, you can have more IBOutlets there and data can be complex object.

0
votes

Also make sure you specify the Reuse identifier properly in your Storyboard view. That has to match what you use in the CellForRowAtIndexPath delegate method. You also have to make sure to change the Class name for the cell in the Storyboard view to your custom TableViewCell class name (MyCell above).