How do copy:/past: messages get sent to NSDocument?
-
I'm going through the NSPersistentDocument Core Data Tutorial, which
leads you through creating a Core Data Document based application. In
the section where they demonstrate implementing copy/paste, they have
you add copy: and paste: methods to the MyDocument class, which is a
subclass of NSPeristentDocument. What I don't see is how these
methods end up getting called. I see in IB that the Copy and Paste
commands are setup to send a copy: and paste: message to the
FirstResponder object. NSDocument is not itself a NSResponder
subclass so I assume it can't be in the responder chain, which means
that there must be some setup in document based apps so that certain
messages get forwarded on to the current NSDocument under some
circumstances. Does anyone know where this is documented, so I can
see exactly which events get forwarded to the document and under which
circumstances? Thank you.
Adam -
> Does anyone know where this is documented, so I can
> see exactly which events get forwarded to the document and under which
> circumstances?
No, nobody's discovered how this works yet. It's a deep,
impenetrable mystery, a black art the depths of which not even Apple
fully grasps. Of course I'm kidding. :-)
The Cocoa Fundamentals guide is your best friend:
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals
/CommunicatingWithObjects/chapter_6_section_5.html#
There's also this (see the very last paragraph):
http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/EventOverview/Eve
ntArchitecture/chapter_2_section_6.html#
Google will also help (try googling "cocoa first responder").
You may not like the bluntness of this, but it's meant to be helpful
*and* realistic: You're trying to run before you can walk. Your best
bet is to take a detour from the advanced technologies (Core Data,
Cocoa Bindings, etc.) and make sure you've mastered the basics (or at
least the organization of the documentation). What you're looking for
is critical to your understanding of many aspects of Cocoa. If you
don't have that down yet, you're in for a world of hurt trying to
understand the more complicated parts.
--
I.S. -
On Feb 25, 2008, at 4:09 PM, I. Savant wrote:>> Does anyone know where this is documented, so I can
>> see exactly which events get forwarded to the document and under
>> which
>> circumstances?
>
> No, nobody's discovered how this works yet. It's a deep,
> impenetrable mystery, a black art the depths of which not even Apple
> fully grasps. Of course I'm kidding. :-)
>
> The Cocoa Fundamentals guide is your best friend:
>
> http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals
/CommunicatingWithObjects/chapter_6_section_5.html#
>
> There's also this (see the very last paragraph):
>
> http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/EventOverview/Eve
ntArchitecture/chapter_2_section_6.html#
Thank you very much for the pointers.> You may not like the bluntness of this, but it's meant to be helpful
> *and* realistic: You're trying to run before you can walk. Your best
> bet is to take a detour from the advanced technologies (Core Data,
> Cocoa Bindings, etc.) and make sure you've mastered the basics (or at
> least the organization of the documentation).
I'm not sure how you assume that from this single question. I do
already understand Cocoa's binding system pretty well, especially
since it's quite similar to what Smalltalk has had for many years, and
Java's bindings framework as well. I've got about 15 years of
professional development experience, including a bit of database
programming, using various ORM systems, various GUI frameworks in C++,
Java, Smalltalk, etc, so none of the Cocoa technologies seem
particularly novel or hard to understand. I just find the
organization of Apple's documentation especially unintuitive compared
to other libraries and frameworks I've used. Often important
information about a class is buried somewhere in some related guide
rather than in the class's documentation itself, so I don't know about
it until I happen to stumble across the information while learning
about something else.
Anyway, sorry for the rant, and thanks again for your pointers.
Adam -
On Feb 25, 2008, at 5:03 PM, Adam P Jenkins wrote:> I'm not sure how you assume that from this single question. I do
> already understand Cocoa's binding system pretty well, especially
> since it's quite similar to what Smalltalk has had for many years,
> and Java's bindings framework as well.
You're right that it was an assumption, but you used the words,
"first responder". Searching the documentation for those words
produces the links I sent you and more. I have no idea how much you
know, just that you skipped over a fairly obvious search. With that in
mind, is it any wonder I made such an assumption?
--
I.S.


