Tuesday, June 26, 2012

Monotouch Gotcha : Dispose all outlets

If you have used winforms than you should be familiar with this pattern. Whenever you are done with a window be sure to call Dispose of any other windows that you have a reference to. The reason is that the windows are natively linked to OS windows and in your Dispose you are supposed to release any references to native resources.

In monotouch, even outlets are native objects. So be careful with them. In fact the default monotouch templates point you in the right direction as shown : 


The ReleaseDesignerOutlets automatically adds the code to release any outlets that are created using Interface Builder inside of Xcode:



Of course non-native (managed) resources are not your responsibility : http://stackoverflow.com/a/6620835/390330 

No comments:

Post a Comment