• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Changes to -makeDocumentWithContentsOfURL:ofType:error: in the last couple of OS releases?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Changes to -makeDocumentWithContentsOfURL:ofType:error: in the last couple of OS releases?


  • Subject: Re: Changes to -makeDocumentWithContentsOfURL:ofType:error: in the last couple of OS releases?
  • From: Quincey Morris <email@hidden>
  • Date: Thu, 01 Nov 2012 01:59:07 -0700

On Nov 1, 2012, at 00:53 , Rick Mann <email@hidden> 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@hidden)

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:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Changes to -makeDocumentWithContentsOfURL:ofType:error: in the last couple of OS releases?
      • From: Rick Mann <email@hidden>
References: 
 >Changes to -makeDocumentWithContentsOfURL:ofType:error: in the last couple of OS releases? (From: Rick Mann <email@hidden>)

  • Prev by Date: Changes to -makeDocumentWithContentsOfURL:ofType:error: in the last couple of OS releases?
  • Next by Date: Re: Changes to -makeDocumentWithContentsOfURL:ofType:error: in the last couple of OS releases?
  • Previous by thread: Changes to -makeDocumentWithContentsOfURL:ofType:error: in the last couple of OS releases?
  • Next by thread: Re: Changes to -makeDocumentWithContentsOfURL:ofType:error: in the last couple of OS releases?
  • Index(es):
    • Date
    • Thread