NSDocument initWithContentsOfURL vs readFromURL

  • When I open a document from a file (double clicking or via File-Open), my
    Document object gets

    -(id)initWithContentsOfURL:(NSURL *)absoluteURL ofType:(NSString *)typeName
    error:(NSError **)outError

    It seems like I could just read the file there and load it into my internal
    structures in my Document instance.

    Why then is there the method below (and when would it be called)?

    -(BOOL)readFromURL:(NSURL *)absoluteURL ofType:(NSString *)typeName
    error:(NSError **)outError
  • On 20 May 2013, at 11:29, Trygve Inda <cocoadev...> wrote:

    > When I open a document from a file (double clicking or via File-Open), my
    > Document object gets
    >
    > -(id)initWithContentsOfURL:(NSURL *)absoluteURL ofType:(NSString *)typeName
    > error:(NSError **)outError
    >
    > It seems like I could just read the file there and load it into my internal
    > structures in my Document instance.
    >
    > Why then is there the method below (and when would it be called)?
    >
    > -(BOOL)readFromURL:(NSURL *)absoluteURL ofType:(NSString *)typeName
    > error:(NSError **)outError

    -readFromURL:… is used both for creating documents, and when reverting a document. The latter is especially important for Versions integration.
previous month may 2013 next month
MTWTFSS
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    
Go to today