Thanks very much for your advice. 

After receiving your email I set the filetype in the object's init method:

    [self setFileType:FILEEXTENSION_QUICKLOOK]; //#define 
FILEEXTENSION_QUICKLOOK         @"CAQuickLook"

However, saving the file as before, still does not append a file extension. 

On the call to:

        [self saveDocumentWithDelegate:self 
didSaveSelector:@selector(didSaveDocument:didSave:contextInfo:) 
contextInfo:nil];

...I get this message from XCode:

        2011-09-03 15:15:01.954 CATab[12618:903] -[NSDocumentController 
fileExtensionsFromType:] is deprecated, and does not work when passed a uniform 
type identifier (UTI). If the application didn't invoke it directly then the 
problem is probably that some other NSDocument or NSDocumentController method 
is getting confused by a UTI that's not actually declared anywhere. Maybe it 
should be declared in the UTExportedTypeDeclarations section of this app's 
Info.plist but is not. The alleged UTI in question is "CAQuickLook".

I went to the XCode App Properties panel and added an Exported UTI with file 
extension of "CAQuickLook". However, saving the document, still does not append 
a file extension to the file name. 

What am I missing?



On Sep 3, 2011, at 2:12 PM, Lee Ann Rucker wrote:

> Have you set [NSDocument fileType]?
> You can get the extension from [NSString pathExtension]
> 
> 
> ----- Original Message -----
> From: "Vik Rubenfeld" <v...@mindspring.com>
> To: cocoa-dev@lists.apple.com
> Sent: Saturday, September 3, 2011 12:33:13 PM
> Subject: Best Practices for Associating a File Extension With a File in       
> XCode 4?
> 
> I see that NSDocument has lots of great support for saving files, including:
> 
>    [self saveDocumentWithDelegate:self 
> didSaveSelector:@selector(didSaveDocument:didSave:contextInfo:) 
> contextInfo:nil];
> 
> NSDocument supports several methods for providing info on the document to be 
> saved, including:
> 
>       - (NSURL *)fileURL //document's location
>       - (NSData *)dataOfType: (NSString *)type error:(NSError **)error 
> //document's data
>       ...etc.
> 
> But I don't yet see a method that returns the file extension for the file.
> 
> Going to the app project settings, I filled in a document type as shown in 
> this image:
> 
> http://tinyurl.com/3v6hezq
> 
> As shown in the image, I filled in a file extension for documents of the 
> document type, "QuickLookOutputDocument," which is one of my app's objects, a 
> subclass of NSDocument. I thought that perhaps this file extension would be 
> used when the document was saved. However, although the data of the document 
> is saved correctly, using:
> 
>    [self saveDocumentWithDelegate:self 
> didSaveSelector:@selector(didSaveDocument:didSave:contextInfo:) 
> contextInfo:nil];
> 
> ...no file extension was used.
> 
> What am I missing?
> 
> Thanks very much in advance to all for any 
> info._______________________________________________
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/lrucker%40vmware.com
> 
> This email sent to lruc...@vmware.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to