Re: Creating new/untitled NSPersistentDocuments from template documents?
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