{ by david linsin }

August 06, 2010

Improve your dealloc method

If you are programming for any iOS device, chances are high, you've came across properties. They give you these tedious accessor methods for free and in addition to that some nice memory management features.

While explaining a colleague how to implement dealloc, he pointed me to the excellent Objective-C guide of Cocoa Dev Central.

You can see a pretty straightforward implementation of an Objective-C class there, with an implementation of dealloc, the way you are used to. However, since we have synthesized getters and setters, we can simply write the following:

Basically, the implementation of the accessor at runtime handle memory management for us here, which I think is pretty neat.

0 comments:


com_channels

  • mail(dlinsin@gmail.com)
  • jabber(dlinsin@gmail.com)
  • skype(dlinsin)

recent_postings

loading...