views:

62

answers:

2

I am an experienced developer, new to Mac development, so I

There are still lots of gaps, and I'm having a hard time finding good readables. Some of my questions are listed below. These are very simple/general. There must be a short, concise doc that details the basic app bootstraping process, and all involved classes. Thanks!

  • The "delegate" that gets generated by XCode contains instances of NSPersistentStoreCoordinator, NSManagedObjectModel, and NSManagedObjectContext -- details please?
  • The delegate is declared "@interface tests_AppDelegate : NSObject {" . Why is the protocol missing? I see examples on the net with it there.
  • I see that the application delegate is instantiated inside Interface Builder. Where is it passed into the NSApplication instance?
+1  A: 
  1. That only happenes if you use the template for a CoreData-based apps. Read Core Data basics.

  2. The protocol was only formalized in OS X 10.6. It was done informally prior to that. As long as the delegate implements the selector mentioned in the reference, it gets called. It's not strictly necessary for the delegate to explicitly adopt a protocol. Of course it's better to do that. See NSApplicationDelegate reference. Every entry has the comment

    Available in Mac OS X v10.0 and later. Available as part of an informal protocol prior to Mac OS X v10.6.

  3. In the Interface Builder you see the delegate is assigned to the "delegate" outlet of the File's Owner: right-click on the File's Owner and you can see that. The nib files contain freeze-dried objects created in the IB. When the app reads MainMenu.nib as part of the initialization process, it assigns NSApp as the File's Owner. So the app delegate instantiated and frozen inside the nib file gets assigned to NSApp's delegate. Read Nib Files.

Yuji
+1  A: 

The "delegate" that gets generated by XCode contains instances of NSPersistentStoreCoordinator, NSManagedObjectModel, and NSManagedObjectContext -- details please?

That's Core Data stuff.

The delegate is declared "@interface tests_AppDelegate : NSObject {" . Why is the protocol missing? I see examples on the net with it there.

Probably an oversight. AppKit didn't always have a formal NSApplicationDelegate protocol. It's possible that Apple simply never updated the templates. You might file a bug.

I see that the application delegate is instantiated inside Interface Builder. Where is it passed into the NSApplication instance?

Right-click on the application object. You'll find that its delegate outlet is connected to the delegate object.

Peter Hosey