• 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: New Document With A Default Name and Default Path
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New Document With A Default Name and Default Path


  • Subject: Re: New Document With A Default Name and Default Path
  • From: "Kirt Cathey" <email@hidden>
  • Date: Sat, 21 May 2005 02:24:25 +0000

Thanks Cameron.

You sent me in the right direction.

It is important that questions like this eventually get answered with a code snippet, so I dedicate this to archive:

+ (void) createMyDocument:(NSURL *)docURL
{
[self init];

NSURL *thisURL = docURL;
MyDocument *thisDocument = [[MyDocument alloc]init];
[thisDocument setMyURL:docURL];

[[NSDocumentController sharedDocumentController] newDocument:nil];
thisDocument = [[NSDocumentController sharedDocumentController] currentDocument];
[thisDocument setFileURL:thisURL];
[thisDocument setFileType:@"WorkPapers"];
[thisDocument saveToURL:thisURL ofType:@"WorkPapers" forSaveOperation:NSSaveOperation error:nil];
}


- (void)windowWillClose:(NSNotification *)notification
{
	[self saveDocument:self];
}

Put this in MyDocument and call it from anywhere else to make a document that creates itself and always saves itself.

If anybody sees any room for improvement, please include your comments.

Regards,
Kirt

From: Cameron Hayne <email@hidden>
To: CocoaDev list <email@hidden>
CC: Kirt Cathey <email@hidden>
Subject: Re: New Document With A Default Name and Default Path
Date: Tue, 17 May 2005 06:15:03 -0400

On 17-May-05, at 4:37 AM, Kirt Cathey wrote:
 I want to create a new document saved
automatically at a default path with a pre-assigned name

Assuming you are using the NSDocument architecture (you should), it seems to me (I haven't tested this) that you can do this with NSDocument's setFileName: followed by saveDocument:


--
Cameron Hayne
email@hidden



_________________________________________________________________
無料250MBメールボックスのMSN Hotmail https://registernet.passport.net/reg.srf?id=2&lc=1041


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: New Document With A Default Name and Default Path (From: Cameron Hayne <email@hidden>)

  • Prev by Date: CoreData and NSTextView
  • Next by Date: Re: Can an object's relationship point to itself?
  • Previous by thread: Re: New Document With A Default Name and Default Path
  • Next by thread: Sharing instances between NIB's?
  • Index(es):
    • Date
    • Thread