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.
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.
That only happenes if you use the template for a CoreData-based apps. Read Core Data basics.
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.
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.
发布评论
评论(2)
这是核心数据内容。
可能是一个疏忽。 AppKit 并不总是有正式的 NSApplicationDelegate 协议。苹果可能根本就没有更新过这些模板。您可以提交错误。
右键单击应用程序对象。您会发现它的
delegate
出口已连接到委托对象。That's Core Data stuff.
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.
Right-click on the application object. You'll find that its
delegate
outlet is connected to the delegate object.只有当您将模板用于基于 CoreData 的应用程序时,才会发生这种情况。阅读 核心数据基础知识。
该协议仅在 OS X 10.6 中正式化。在此之前,这是非正式完成的。只要委托实现了参考中提到的选择器,它就会被调用。代表并不严格需要明确采用协议。当然最好还是这样做。请参阅 NSApplicationDelegate 参考。每个条目都有评论
<块引用>
适用于 Mac OS X v10.0 及更高版本。
在 Mac OS X v10.6 之前作为非正式协议的一部分提供。
该协议
在界面生成器中,您会看到委托被分配给文件所有者的“委托”出口:右键单击文件所有者,您可以看到这一点。 nib 文件包含在 IB 中创建的冻干对象。当应用程序在初始化过程中读取
MainMenu.nib
时,它会分配NSApp
作为文件的所有者。因此,在 nib 文件中实例化并冻结的应用程序委托被分配给 NSApp 的委托。阅读 Nib 文件。。 p>
That only happenes if you use the template for a CoreData-based apps. Read Core Data basics.
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
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 assignsNSApp
as the File's Owner. So the app delegate instantiated and frozen inside the nib file gets assigned to
NSApp
'sdelegate
. Read Nib Files.