-4

I am getting ready to update an iOS 6 iPhone app to iOS8. The second line of this code produces an error message ("text" is deprecated. First deprecated in iOS 3.0). The syntax error has been in my app for years not causing a problem but I thought I would clean up any errors before completing my iOS 8 version.

- (void)tableView:(UITableView *)tv1 didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    [appDelegate muniClicked:[[tableView cellForRowAtIndexPath:indexPath] text]];
    NSLog(@"cell clicked {%d, %d}}", indexPath.row, indexPath.section);

}
jscs
  • 63,694
  • 13
  • 151
  • 195
DaveW01
  • 3
  • 2
  • What exactly is your question? – jscs Jul 17 '14 at 18:45
  • 3
    Did you look at the docs for `UITableViewCell`? The `text` property has been deprecated since iOS 3.0! The docs tell you what to use in its place. – rmaddy Jul 17 '14 at 18:49

2 Answers2

0

Instead of using [[tableView cellForRowAtIndexPath:indexPath] text] to get the text displayed in your UITableViewCell, try this:

[[[tableView cellForRowAtIndexPath:indexPath] textLabel] text]

Reference from the UITableViewCell documentation.

Depending on your cell structure, looking at detailTextLabel may also be useful, if you're using that as well.

username tbd
  • 9,152
  • 1
  • 20
  • 35
  • Thank you for your assistance. I originally tried your suggestion but left of the extra [ bracket. – DaveW01 Jul 17 '14 at 19:36
0

You can use this code as in default UITableViewCell there are two labels textLabelfor main text and detailTextLabel for detailed text.So you can access the text of UITableViewCell by textLabel.text for main label

- (void)tableView:(UITableView *)tv1 didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    [appDelegate muniClicked:[[tableView cellForRowAtIndexPath:indexPath] textLabel.text]];
    NSLog(@"cell clicked {%d, %d}}", indexPath.row, indexPath.section);

}
codester
  • 36,891
  • 10
  • 74
  • 72