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: Steve Mills <email@hidden>
- Date: Fri, 01 May 2015 14:09:15 -0500
On May 1, 2015, at 14:02:27, Sean McBride <email@hidden> wrote:
> 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. :(
What happens with the doc after initWithTemplate? Are standard document or doc controller methods acting on it? Try overriding setFileURL: (or just set a symbolic breakpoint on it) so you can see if something is setting the url after your initWithTemplate method. Or try calling setFileURL before readFromURL.
--
Steve Mills
Drummer, Mac geek
_______________________________________________
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