Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone SDK 3.0 Vs. 2.2.1

I just installed iPhone SDK 3.0 and found that the text property of UITableViewCell is not used anymore, and should use textLabel.text instead. Does this mean that I have to know the current system version and call the corresponding method? like this.

UITableViewCell *cell = ...;
if ([[[UIDevice currentDevice] systemVersion] isEqualToString:@"3.0"]) {
  cell.textLabel.text = @"...";
} else {
  cell.text = @"...";
}

If so, that would be very annoying.

like image 242
Joey Avatar asked Jan 24 '23 11:01

Joey


2 Answers

Instead of checking the OS version, you can check if the cell has the new property:

if ([cell respondsToSelector:@selector(textLabel)]) {
  // Do it the 3.0 way
  cell.textLabel.text = @"...";
} else {
  // Do it the 2.2 way, but avoid deprecation warning
  [cell performSelector:@selector(setText:) withObject:@"..."];
}
like image 169
Chris Lundie Avatar answered Jan 26 '23 00:01

Chris Lundie


Just build for 3.0 and don't worry about 2.2 anymore. Unlike major OS upgrades, people have been upgrading to new version of iPhone OS very, very quickly. Check out this post on the TapBots blog: iPhone 3.0 Adoption Rate.

By the time your app gets approved (2 weeks from now + some?) almost nobody will be using 2.2 anymore!

like image 43
Ben Gotow Avatar answered Jan 26 '23 02:01

Ben Gotow