2

I am working on a large iOS application and am at the phase where I'm doing some cleanup/performance tuning.

One of the things I need to do is override ViewDidUnload everywhere and take the appropriate action, and the most common thing that needs to be done is to set all outlets within the UIViewController to null. Is there a way through MonoTouch APIs to get a list of connected outlets in a UIViewController? This will make this process much more robust, as I won't have to do anything if I add new outlets.

NOTE: I know setting all outlets to null won't catch every referenced view, but should get a large portion.

palacsint
  • 28,416
  • 10
  • 82
  • 109
jonathanpeppers
  • 26,115
  • 21
  • 99
  • 182
  • Reflection is the first thing that comes to mind. However, I do not think this is what you are looking for... – Dimitris Tavlikos Dec 16 '11 at 19:19
  • Yeah, I was hoping MonoTouch had them cached where reflection wouldn't be required. Although it might be a decent option (I will maybe try a quick speed test). – jonathanpeppers Dec 16 '11 at 19:42

1 Answers1

1

Looks like Xamarin has been at work to fix this in the latest version of MonoTouch/MonoDevelop .

There is a designer-generated ReleaseDesignerOutlets() that you can call in ViewDidUnload. You can view the method in any *.designer.cs file.

Not sure if there is a good way to fix existing views created prior to the latest MonoDevelop, however.

jonathanpeppers
  • 26,115
  • 21
  • 99
  • 182
  • If you reopen all your xibs in Xcode and then just add a blank line in each of the header files generated for use with drag&dropping outlets/actions, MonoDevelop will re-parse those header files and regenerate the .designer.cs file, adding the ReleaseDesignerOutlets() method implementation. – jstedfast Feb 02 '12 at 21:29