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

Create and save a NSPersistentDocument from scratch


  • Subject: Create and save a NSPersistentDocument from scratch
  • From: Eric Morand <email@hidden>
  • Date: Wed, 11 Nov 2009 13:34:46 +0100

Hi guys !

I'm trying to implement a "welcome screen" like the ones found in Garage Band or Xcode : the user will be showed a window with a "Create new document" button that, when clicked, show a save panel. Once saved, the application should open the document.

I'm facing a problem when I try to save the newly created document on the disk : the application raise an error ('The document 'MyDoc' could not be saved").

Here is the code I use to show the save panel and save the document to the disk :

- (IBAction)createNewDocument:(id)sender {
	NSSavePanel * savePanel = [NSSavePanel savePanel];

	[savePanel beginSheetForDirectory:nil
		file:NSLocalizedString(@"MyDoc", @"")
		modalForWindow:[self window]
		modalDelegate:self
		didEndSelector:@selector(savePanelDidEnd:returnCode:contextInfo:)
		contextInfo:nil];
}

- (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];
}

Can someone help me on this ?


Thanks by advance,

Eric.
_______________________________________________

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>
  • Prev by Date: Re: How to detect mac version (macbook version xx, mac version xx etc.)
  • Next by Date: Snow Leopard: Problem with searching .flv files.
  • Previous by thread: Re: How to detect mac version (macbook version xx, mac version xx etc.)
  • Next by thread: Re: Create and save a NSPersistentDocument from scratch
  • Index(es):
    • Date
    • Thread