Fixed the icon-fetching method for configurations in which CFBundleIconFile has the icns extension in the value.

This commit is contained in:
andym committed 2007-12-25 01:47:26 +00:00
1 parent 5aa1e18bc5
commit c7b616ce1d
1 file changed
+9 -3
+9 -3
View File
@@ -43,11 +43,17 @@
{
// Cache the application icon.
NSString *iconPath = [self pathForResource:[self objectForInfoDictionaryKey:@"CFBundleIconFile"] ofType:@"icns"];
// According to the OS X docs, "CFBundleIconFile - This key identifies the file containing
// the icon for the bundle. The filename you specify does not need to include the .icns
// extension, although it may."
//
// However, if it *does* include the '.icns' the above method fails (tested on OS X 10.3.9) so we'll also try:
if (!iconPath)
iconPath = [self pathForResource:[self objectForInfoDictionaryKey:@"CFBundleIconFile"] ofType: nil];
NSImage *icon = [[[NSImage alloc] initWithContentsOfFile:iconPath] autorelease];
if (icon)
return icon;
else // Use a default icon if none is defined.
return [[NSWorkspace sharedWorkspace] iconForFileType:NSFileTypeForHFSTypeCode(kGenericApplicationIcon)];
return icon; else // Use a default icon if none is defined.
return [[NSWorkspace sharedWorkspace] iconForFileType:NSFileTypeForHFSTypeCode(kGenericApplicationIcon)];
}
- (BOOL)isRunningFromDiskImage