0

In regards to this posting Why does 'self' protect memory space?, I'm using 'self' to access aArray. Yet, I still get an invalid object in the didSelectRowAtIndexPath: method.

In the root controller, I access aArray like this:

MyAppDelegate *theDelegate = [[UIApplication sharedApplication] delegate];  
NSString *aKey = [theDelegate.aArray objectAtIndex:0];

Would that have something to do with aArray loosing its reference? Why wouldn't it occur in cellForRowAtIndexPath: (the first use of it outside of MyAppDelegate proper)?

Community
  • 1
  • 1
4thSpace
  • 43,672
  • 97
  • 296
  • 475

2 Answers2

2

This question doesn't make sense. Or, rather, the answer is still "go read and understand the documentation linked to in the answer to your other question".

Specifically:

There is no magic about memory management. There is nothing special about self vs. any other kind of object reference. The dot notation is merely short hand for a method call; nothing special to it, either.

Until you understand these things, you'll be chasing ghosts and not actually solving the real problems in your code.

Community
  • 1
  • 1
bbum
  • 162,346
  • 23
  • 271
  • 359
1

If aArray is a property that is set to retain, then you may be over-releasing it somewhere. It doesn't seem entirely clear in your question, but if it's the object at index 0 that's invalid, it may be it that was over-released. If you're using Xcode 3.2 on Snow Leopard you may want to make sure you're using the Clang static analyzer. It can help find such over-releases.

Cory Kilger
  • 13,034
  • 3
  • 33
  • 24