Sammy
Sammy

Reputation: 1218

iOS UIBuilder setting CustomClass for tablecell - why

Why should I set a Custom-class for a Cell within the UIBuilder? All examples I can find are setting the Identifier and use this on in ...cellForRowAtIndexPath:...?

Is this useless here?


Edit:

Sorry, I think, this was not asked clearly - so I'll try again:

Upvotes: 1

Views: 59

Answers (1)

Joey Clover
Joey Clover

Reputation: 776

If you use Custom Cells in the Interface Builder, you can easily manipulate the appearance of your custom cell, and make it have custom properties and behave in specific ways which is very effective.

Custom Class is used whenever you make your own class for a UITableViewCell.

#import "UITableViewCell.h"

@interface MyCell : UITableViewCell

@property NSString *myCustomProperty;

@end

Then in the code, you can access the custom properties of your cell by doing something like:

MyCell *cell = (MyCell*)[tableView objectAtIndexPath:indexPath];
[cell setMyCustomProperty:@"Custom Cells Yey!"];

Also, may I also note that the identifiers are primarily used to manage memory effectively in UITableViews. The table views use trickery in their implementation to cache the cells rather than create new cells every time you scroll a little bit otherwise that would be overkill so you can use identifiers to cache rows in the tableview automagically.

Upvotes: 1

Related Questions