Monday 15 March 2010

Is Default Xcode 4.6.3 New Project With Cocoa Application Template Structure Recommended? -


I am using Xcode 4.6.3, and I created a new project using the "Cocoa App" template is. The default structure looks a bit awkward for me, and I was thinking that this is the recommended structure.

Specifically, there are three files created by the template:

  • MainMenu.xib
  • AppDelegate .h
  • AppDelegate.m

    Main menu. Xib contains the main menu definition and the definition of the main window. It seems strange to me that the main window is defined in a file called MainMenu.xib . Is this the recommended place to define the main window?

    I was expecting to see files like MainWindow.h , and MainWindow to NSViewController subclassed . The existing structure created from the template will inspire me to create handlers for the main window event in app representatives. It seems strange to me Is the app representative advised to put main window outlets and handlers?

    One of the first things that gets me out of the window.

    I was hoping to see a file like MainWindow, and the main window Subclass from NSVIIUI Controller

    What do I do (after removing the window from the main menu nib) has created an window I controller sub-class, objective-class file template By using and to enable "enabled" and "nib", please, please. Option (which appears when Superclass is NSViewController or NSWindowController).

    (Do not forget to select the nib later and click the button in the file inspector to localize it, because Xcode does not do this for some reason by default.)

    In the implementation of sub-classes, I have something like the following:

      @migrationMyWindowController- (instancetype) init {return [self InitWithWindowNibName: NSStringFromClass ([self class])]; } // and all my app-specific stuff in @end   

    In the app representative, I remove the outlet which once referred to the menman-born window, and then I Make Window Controller: @implementation MyAppDelegate {MyWindowController * _wc; } - (Zero) ApplicationFlight Launching: (NSNextification *) Notification {_wc = [Myvando Controller New]; [_wc showWindow: zero]; } --Explore the application (zero): (nsnification *) notification {[_wc close]; _wc = zero; } @ And

    (I use ARC; if you do not, then you want to add a release message there.)

    Is the app representative advised to keep main window outlets and handlers?

    No. It is beyond the scope of what the representative of the application should do.

    For an extremely simple one-window app, you want to make the controller of the window a representative of the app. But it is also different from making an App Representative which is not a window controller handle action, a data source is created etc. There is a difference in adding a little responsibility for this window controller and adding total responsibility to it.

    I keep them separate at all times. This is a bit of extra work in simple cases, but my project is cleaner, which makes me happy, and usually I have to do it sooner or later.

No comments:

Post a Comment