The past few months I've been working in objective-C since I've been doing some contract iPhone development work. I actually really like the platform. iOS is pretty fun to code for. However, it can also be incredibly frustrating--especially coming from using Visual Studio and C#.
One of the things that stopped me for a while was that I noticed that my views were not being properly unloaded in a UINavigationController setup. Whenever I popped the view, I noticed that the retain count on it stayed above 0. If I pushed on a new view, it would add 1 to it and continue until I hit a memory error.
I knew something was holding onto it but I had no idea what--I was sending release statements to everything I retained. Then after some digging around, I discovered what was going on.
By accident, I had my custom delegates I wrote marked with (retain) in the property. This lead to one of those nasty retain cycles, which means that even though I was releasing the view, the delegate still owned it.
So I changed it to (assign) and re-loaded the app. Success! It now properly completely released and deallocated the view. Here's a quick code snippet:
@property (assign) id<MyCustomDelegate> customDelegate;
Hope this helps!