On Nov 1, 2012, at 00:53 , Rick Mann <[email protected]> wrote:
> I have some old code that would try to open a file using
> -openDocumentWithContentsOfURL:display:error:, if it existed and if it does
> not exist, would call -makeDocumentWithContentsOfURL:ofType:error: on that
> same URL, in an effort to create the missing document.
No, that's not what these are for. They both are used in opening an existing
document file.
> The code clearly expected to receive a valid document object from the call,
> but instead it's returning nil and setting the error: Error
> Domain=NSCocoaErrorDomain Code=260 "The file couldn’t be opened because it
> doesn’t exist."
>
> Now, maybe this code never worked properly; it's a project I haven't touched
> in a long time. But has the behavior of this method changed in the last
> couple of OS releases? I have one of these default documents on disk; I just
> can't remember if I created with this code or some other means.
>
> What's the difference between -openDocument… and -makeDocument…?
It's fairly extensively documented in the NSDocumentController class reference:
https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSDocumentController_Class/Reference/Reference.html
Very roughly, the 'make' method is used just to create a NSDocument object. The
'open' document does higher level stuff like bailing if a document object
already exists for the file, or invoking the 'make' method and creating window
controllers.
NSDocumentController has two hierarchies of behavior, starting from the action
methods 'openDocument:' and 'newDocument:'. Each level of the hierarchy is
documented, so that you can override it yet know what the standard behavior is.
_______________________________________________
Cocoa-dev mailing list ([email protected])
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 [email protected]