MonoTouch universal iPhone/iPad app & code duplication
The MonoDevelop IDE, for MonoTouch app, creates separate classes and AppDelegates for iPhone/iPad and there doesn't seem to be an easy way to inherit them from the same base class. Having separa开发者_JAVA技巧te AppDelegate classes would likely result in code duplication in the application.
Can anyone suggest a better app structure for the universal iPhone/iPad app than the one produced by the MonoDevelop IDE?
Alternatively, can anyone suggest any way to have the code common to both AppDelegates not be duplicated?
Thanks in advance.
I don't use MonoTouch (I like the features Objective-C provides a lot) myself, but according to their docs it supports normal object inheritance. So just create your own AppDelegate with the commonly reused methods in it which inherits from MonoTouch.UIApplicationDelegate
. Then modify the AppDelegates generated by the Universal application template to inherit from your custom AppDelegate, and remove any methods in those which your base class implements.
精彩评论