Cocoa without Interface Builder, initialize an instance of app controller?

后端 未结 3 1199
太阳男子
太阳男子 2020-12-30 16:24

I don\'t plan to write applications without IB, I\'m just in the process of trying to learn more about programming.

How can I get a single instance

3条回答
  •  不知归路
    2020-12-30 17:23

    Another solution to the problem of launching an app without a nib.

    Instead of allocing your own controller, just use the extra parameters in the NSApplicationMain() method:

    int retVal = NSApplicationMain(argc, argv, @"UIApplication", @"MyAppDelegate");
    

    This takes care of all the proper linking one would need.

    Then, the only other thing you'd need to remember is to make your own window and set it to visible.

提交回复
热议问题