• 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: Creating new/untitled NSPersistentDocuments from template documents?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating new/untitled NSPersistentDocuments from template documents?


  • Subject: Re: Creating new/untitled NSPersistentDocuments from template documents?
  • From: Sean McBride <email@hidden>
  • Date: Fri, 01 May 2015 15:02:27 -0400
  • Organization: Rogue Research Inc.

On Fri, 1 May 2015 13:36:49 -0500, Steve Mills said:

>Can’t you just set the document’s url to nil at some point? That’s what
>I do in readFromURL:ofType:error: after reading the file (actually
>before reading, because I don’t access the url again from the document).
>I’m using regular NSDocument, but I’d still expect it to work with
>NSPersistentDocument.

Steve,

Thanks for your reply.

Seems that does not help.

In my NSPersistentDocument subclass I created a new initializer, which stripped of error checking, is basically:

- (instancetype)initWithTemplate
{
 	self = [super init];

 	[self readFromURL:<hidden file in my .app>
		 						    ofType:@"com.rogue-research.foobar"
	 							     error:&error];
  [self setFileURL:nil]; // seems to change nothing

  return self;
}

Indeed I get what looks like a new/untitled document and it has the correct contents from the template file.  When I save I get a save panel and supply a filename for example on the Desktop but then it tries to save to my template anyway with an exception:

 NSUnderlyingException = "Cannot update objects into a read only store.";

readFromURL: seems to have added my template as a persistent store in the persistent store coordinator. :(

Cheers,

--
____________________________________________________________
Sean McBride, B. Eng                 email@hidden
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada

_______________________________________________

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: Creating new/untitled NSPersistentDocuments from template documents?
      • From: Steve Mills <email@hidden>
References: 
 >Creating new/untitled NSPersistentDocuments from template documents? (From: Sean McBride <email@hidden>)
 >Re: Creating new/untitled NSPersistentDocuments from template documents? (From: Steve Mills <email@hidden>)

  • Prev by Date: Re: Bindings across view controllers in OS X storyboards
  • Next by Date: Re: Creating new/untitled NSPersistentDocuments from template documents?
  • Previous by thread: Re: Creating new/untitled NSPersistentDocuments from template documents?
  • Next by thread: Re: Creating new/untitled NSPersistentDocuments from template documents?
  • Index(es):
    • Date
    • Thread