Under the Bridge

Code: UITableViewCell-Compatibility

If you’re trying to maintain iPhone source that uses UITableViewCell — and really, what doesn’t? — across 2.x and 3.x OS version targets, here’s a helpful set of functions for OS version agnosticism from the redoubtable Erica Sadun:

@interface UITableViewCell (Compatibility)

- (void) setLabelText: (NSString *) formatstring, ...;

- (void) setDetailText: (NSString *) formatstring, ...;

- (UILabel *) getLabel; // not 2.x friendly, iffy workaround

- (UILabel *) getDetailLabel;

+ (id) cellWithStyle: (uint) style reuseIdentifier: (NSString *) identifier;

// Must be called during tableView:willDisplayCell:forRowAtIndexPath:

- (void) rectifyDetailLabel;

@end

Handy, that. And whilst checking out her site, we also note that iPhone Developer’s Cookbook 3.0 Edition code is now up at github as well. Goodies everywhere!

h/t: iPhoneSDK!

0