I'm using the Three20 TTMessageController in my app. I've figured out how to use it, adding on a bunch of other stuff (including TTMessageControllerDelegate methods and ABPeoplePickerNavigationControllerDelegate methods). It works great for me, after a bit of a struggle to figure it out.
The trouble I'm having now is a design issue: I want to use it identically in two different places, including with the same delegate methods. My current approach is that I've put all the code into a single class inheriting from NSObject, called ComposerProxy, and I'm just having the two controllers that use it use the proxy, like so:
ComposerProxy *proxy = [[ComposerProxy alloc] initWithController:this];
[proxy go];
The go method constructs the TTMessageController, configures it, adds it to a UINavigationController, and presents it:
[self.controller presentModalViewController: navController animated: YES];
This works great, as I have all my code nicely encapsulated in ComposerProxy and I need only the above two lines anywhere I want to use it.
The downside, though, is that I can't dealloc the proxy variable without getting crashes. I can't autorelease it, either: same problem.
So I'm wondering if my proxy approach is a poor one. How does one normally encapsulate a bunch of behaviors like this without requiring a lot of duplicate code in the classes that use it? Do I need to add a delegate class to my ComposerProxy and make the controller responsible for dismissing the modal view controller in a hypothetical composerDidFinish method or some such?
Many TIA!