Problem saving document with my doc icon
Problem saving document with my doc icon
- Subject: Problem saving document with my doc icon
- From: Peter Teeson <email@hidden>
- Date: Fri, 12 Jul 2013 15:29:21 -0400
OS x Lion 10.7.5, Xcode 4.6.3
In my Document based app I am having trouble saving a document with my document icon.
The Finder still shows the file with the folder icon.
Here is my code:
- (NSFileWrapper *)fileWrapperOfType:(NSString *)typeName
error:(NSError *__autoreleasing *)outError{
if ([self documentFileWrapper] == nil) {
NSFileWrapper * documentFileWrapper = [[NSFileWrapper alloc]
initDirectoryWithFileWrappers:nil];
// Get the main bundle for the app.
NSBundle *mainBundle = [NSBundle mainBundle];
if (mainBundle != NULL) {
// Get the Document Icon
NSString* theIconName = [mainBundle pathForResource:@"GMG" ofType:@"icns"];
NSImage* theDocumentIcon = [[NSImage alloc] initWithContentsOfFile:theIconName];
// NOTE: theDocumentIcon actually contains 5 BitMapRepresentations.
// ???? I think I am supposed to extract one of them and use it ???
// If so how? Which one to choose?
// The .icns file has sizes of 256 x356, 128 x 128, 48 x 48, 32 x 32, and 16 x 16 (high res will be added later}.
// This file was created using Grab to get an image and IconMaker to make the icons from it.
// Preview displays the icons and the Inspector seems to indicate it's correct.
[documentFileWrapper setIcon:theDocumentIcon];
}
[self setDocumentFileWrapper:documentFileWrapper];
}
// add several FileWrappers for images, text, and metaData (as a plist).
. . . .
[[self documentFileWrapper] addFileWrapper:imageFileWrapper];
. . . .
[[self documentFileWrapper] addFileWrapper:metaDataFileWrapper];
return [self documentFileWrapper];
}
// This all works as expected except for the document icon.
The <myApp>-Info.plist has Icon file set to GMG.icns and the Document Type Item 0 Icon File Name set to GMG.icns
TIA for your help
Peter
_______________________________________________
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