On 29 Apr 2012, at 22:47, ecir hana wrote:

> Dear list,
> 
> I'm trying to understand how the things in Cocoa works but I'm
> struggling with one thing. I saw
> http://cocoawithlove.com/2010/09/minimalist-cocoa-programming.html and
> http://casperbhansen.wordpress.com/2010/08/15/dev-tip-nibless-development/
> and I think I somewhat understood.
> 
> Now, I would like to do the same but for a "Document-based
> application". Please, does anyone know of a tutorial or example akin
> to the ones above? Alternatively, what do I need to do to make it
> work? I think I need to create NSDocumentController - but how does it
> relate to NSApplication? And I create NSDocument from there? Frankly,
> I'm bit lost…
I appreciate the intention here.
I would start by creating a NSDocumentBased app using the Xcode template and 
examining it.
This app is fully functional even though it contains just the document class 
and the nib.
The reason it works can be found in info.plist under CFBundleDocumentTypes.
This defines the NSDocument class to use.

In MainMenu.xib you can see that File New sends newDocument: up the responder 
chain.
This passes up the chain to NSApplication which (having loaded Info.plist) 
knows to create an instance of your document class.
To create a document in code just send newDocument: up the responder chain with 
a nil targeted action
[NSApplication sendAction:@selector(newDocument:) to:nil from:self]

Regards

Jonathan Mitchell

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to