Posts Tagged UITableViewCell
Upgrading your iPhone OS 2.0 Application to 3.0 and Deprecation Warnings
Posted by Chris Danielson in iPhone Development on August 2nd, 2009
I just wanted to post a brief entry here regarding getting rid of deprecated warnings when upgrading your iPhone applications from OS 2.0 to 3.x.
The warnings I was getting are as follows:
warning: ‘setImage:’ is deprecated (declared at /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/
iPhoneSimulator3.0.sdk/System/Library/Frameworks/UIKit.framework/
Headers/UITableViewCell.h:199)
warning: ‘setText:’ is deprecated (declared at /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/
iPhoneSimulator3.0.sdk/System/Library/Frameworks/UIKit.framework/
Headers/UITableViewCell.h:199)
Before…
//This worked perfect in OS 2.0 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *UserSettingButtonCellIdentifier = @"UserSetting"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:UserSettingButtonCellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier: UserSettingButtonCellIdentifier] autorelease]; } NSUInteger row = [indexPath row]; UserSetting *rowData = [list objectAtIndex:row]; UIImage *image = [UIImage imageNamed:@"bullet_ball_glass_blue.png"]; if (row != 0) cell.image = image; //WARNING here cell.text = rowData.name; //WARNING here [rowData release]; return cell; } //the tableView method is completely deprecated. - (UITableViewCellAccessoryType)tableView:(UITableView *)tableView accessoryTypeForRowWithIndexPath:(NSIndexPath *)indexPath { return UITableViewCellAccessoryDisclosureIndicator; } |
After, doing the mods to get rid of the deprecated warnings:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *UserSettingButtonCellIdentifier = @"UserSetting"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:UserSettingButtonCellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier: UserSettingButtonCellIdentifier] autorelease]; } NSUInteger row = [indexPath row]; UserSetting *rowData = [list objectAtIndex:row]; UIImage *image = [UIImage imageNamed:@"bullet_ball_glass_blue.png"]; if (row != 0) cell.imageView.image = image; //FIXED here cell.textLabel.text = rowData.name; //FIXED here #ifdef __IPHONE_3_0 //This is a replacement for the tableView method cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; #endif [rowData release]; return cell; } #ifndef __IPHONE_3_0 - (UITableViewCellAccessoryType)tableView:(UITableView *)tableView accessoryTypeForRowWithIndexPath:(NSIndexPath *)indexPath { return UITableViewCellAccessoryDisclosureIndicator; } #endif |
I'm a software developer focused on all facets of enterprise solutions and technologies. Currently, I'm enjoying developing iPhone applications at night while spending much of my day working on Java, .Net and database implementations.
