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: Jerry Krinock <email@hidden>
- Date: Tue, 12 May 2009 18:30:17 -0700
On 2009 May 12, at 13:37, Sean McBride wrote:
Hi all,
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_] ;
...
_______________________________________________
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