Re: Changing name of newly created NSDocument (instead of 'Untitled i')
Re: Changing name of newly created NSDocument (instead of 'Untitled i')
- Subject: Re: Changing name of newly created NSDocument (instead of 'Untitled i')
- From: "Sean McBride" <email@hidden>
- Date: Wed, 13 May 2009 14:14:08 -0400
- Organization: Rogue Research Inc.
On 5/12/09 6:30 PM, Jerry Krinock said:
>> My doc-based application is able to import foreign file formats. I do
>> this by creating a new instance of my NSPersistentDocument subclass
>> and
>> populate it as needed.
>>
>> Works fine, but results in a document named "Untitled i". Is there a
>> way to name it something like "original_filename (Converted)"?
>> setFileURL: doesn't seem appropriate since I don't want to ask the
>> user
>> to choose an on-disk location.
>
>Don't have time to go into the details, but here's what I do...
>
>- (void)saveMoveToNewPath:(NSString*)newPath {
> NSString* oldPath = [[self fileURL] path] ;
> NSString* defaultType = [[NSDocumentController
>sharedDocumentController] defaultType] ;
> NSString* requiredExtension = [SSYAppInfo
>fileExtensionForDocumentType:defaultType] ;
> NSURL* newURL = [NSURL fileURLWithPath:newPath] ;
> if (![[newPath pathExtension] isEqualToString:requiredExtension]) {
> newPath = [newPath
>stringByAppendingPathExtension:requiredExtension] ;
> newURL = [NSURL fileURLWithPath:newPath] ;
> }
> NSError* error_ = nil ;
> BOOL ok = [self saveToURL:newURL
> ofType:[self fileType]
> forSaveOperation:NSSaveOperation
> error:&error_] ;
Jerry,
I appreciate your reply, but that's not what I'm looking for. I should
have been clearer. Your suggestion saves the imported foreign document
to disk as the native format. I'd rather not save anything to disk
because the user may just want to open and view the foreign document, he
may not want to save it at all. But if I do save it, I'd like the save
panel (and document title bar) to show "original_filename (Converted)".
Basically, I'd like opening foreign documents to be like creating new
blank documents but with a UI distinction.
Cheers,
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
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