0

Since KVC is used to set outlets on the iPhone, there are 2 methods (that I know of) to make sure you've properly handled memory management.

Specifically, I am referring to this article written by Aaron Hillegass.

My question is which method do you use and what is your reasoning?

  • Release all your outlets in dealloc and viewDidUnload (Make sure you set them to nil in viewDidUnload.)
  • Make your outlets weak references

Personally, I am leaning towards using weak references as it seems cleaner.

Corey Floyd
  • 25,929
  • 31
  • 126
  • 154

2 Answers2

1

I go with weak references. As you say its less cluttered and makes an already overly verbose code foorprint a little more manageable

ennuikiller
  • 46,381
  • 14
  • 112
  • 137
1

Weak references are easier, yes. Clearer? A retain property as just as clear, and you can be more explicit about when something is released.

Personally I like to primarily use properties to expose some attribute of the class to the outside world - so for IBOutlets only the class will manipulate, I simply declare them without using properties and release them in dealloc.

In either case set to nil IBOutlet references in viewDidUnload.

Kendall Helmstetter Gelner
  • 74,769
  • 26
  • 128
  • 150