Re: New Document With A Default Name and Default Path
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