• 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: Create and save a NSPersistentDocument from scratch
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Create and save a NSPersistentDocument from scratch


  • Subject: Re: Create and save a NSPersistentDocument from scratch
  • From: Eric Morand <email@hidden>
  • Date: Wed, 11 Nov 2009 19:15:30 +0100

> Next, this is a non-standard -- and incorrect-looking -- way to create a NSPersistentDocument. Is there a reason you're not using a NSDocumentController method (such as 'openUntitledDocumentAndDisplay:error:') to create it?

I don't want my user to work with a non-saved document. Ever. For a good reason : since you need a saved document to use the mergeChangesFromContextDidSaveNotification method from NSManagedObjectContext, I don't have other choice than have my user always work with a saved document. That's unfortunately the only solution I've found to be able to use mergeChangesFromContextDidSaveNotification and conform to the "NSManagedObjectContrext is a scratchpad" concept.

> Also, the file type you're specifying doesn't look likely. "SQLite" looks like a store type, not a file type, and the store type isn't specified this way.

You're probably right. But I don't know what is the file type of my document. I've searched everywhere in the plist and I didn't find any mention of "file type".

> Finally, you're turning the usual mechanism inside out by *first* running the save panel yourself, then creating a new document, then trying to save the document but *suppressing* the save panel that would normally appear because the document is new. Is there a reason for that?

I'd like to have the save panel open as a sheet, not a modal window. And the standard behavior open a modal window. Is there a way to customize this ?



Thanks for your help,


Eric.

Le 11 nov. 2009 à 19:01, Quincey Morris a écrit :

> On Nov 11, 2009, at 04:34, Eric Morand wrote:
>
>> - (void)savePanelDidEnd:(NSSavePanel *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo {
>> 	if (returnCode == NSOKButton) {
>> 		NSPersistentDocument * newDoc = [[[NSPersistentDocument alloc] init] autorelease];
>>
>> 		[newDoc setFileType:@"SQLite"];
>> 		[newDoc setFileURL:[sheet URL]];
>> 		[newDoc saveDocument:self];
>> 	}
>>
>> 	[sheet orderOut:self];
>> }
>
> Seems like you're abusing NSPersistentDocument.
>
> For a start, it seems likely you want to subclass it, not create an instance of it. Most documents have some kind of transient state, or method overrides, that require a subclass. It's prima facie possible that your documents don't, so perhaps it's OK, but it's certainly unusual.
>
> Next, this is a non-standard -- and incorrect-looking -- way to create a NSPersistentDocument. Is there a reason you're not using a NSDocumentController method (such as 'openUntitledDocumentAndDisplay:error:') to create it?
>
> Also, the file type you're specifying doesn't look likely. "SQLite" looks like a store type, not a file type, and the store type isn't specified this way.
>
> Finally, you're turning the usual mechanism inside out by *first* running the save panel yourself, then creating a new document, then trying to save the document but *suppressing* the save panel that would normally appear because the document is new. Is there a reason for that?
>
>
> _______________________________________________
>
> 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

_______________________________________________

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: Create and save a NSPersistentDocument from scratch
      • From: Quincey Morris <email@hidden>
References: 
 >Create and save a NSPersistentDocument from scratch (From: Eric Morand <email@hidden>)
 >Re: Create and save a NSPersistentDocument from scratch (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: View swap using "push" animation
  • Next by Date: Re: Weird problem with Core Text
  • Previous by thread: Re: Create and save a NSPersistentDocument from scratch
  • Next by thread: Re: Create and save a NSPersistentDocument from scratch
  • Index(es):
    • Date
    • Thread