views:

13

answers:

1

I have a UITableView with about 20 cells. I wanted to make a pointer to three of those cells, so I set up a property for those, then pointed them to those cells:

if ([item.title isEqualToString:@"Test1"]) {
  test1 = cell;
} else if ([item.title isEqualToString:@"test2"]) {
  test2 = cell;
}

If I scroll up and down in my table view over and over it will crash my app. But, removing this pointer code fixes the crashing issue.

Why would making a pointer to a cell make my app crash?

Edit:

if ([item.title isEqualToString:@"Test1"]) {
        self.test1 = cell;
} else if ([item.title isEqualToString:@"test2"]) {
        self.test2 = cell;
}

I just updated my code to use self. and it seems to fix the crashing issue. Could this be true?

+1  A: 

You have to use self. if you want to call the property, if no, you are just calling your instance variable.

And with property, I think that it already supports you with (retain) then you really owns the test1 and test2 and later on, you can call method on them

vodkhang
Thanks, I appreciate you verifying this.
Nic Hubbard