From c7b616ce1de9cd89b6165eef7afe190b99ae5f85 Mon Sep 17 00:00:00 2001 From: andym Date: Tue, 25 Dec 2007 01:47:26 +0000 Subject: [PATCH] Fixed the icon-fetching method for configurations in which CFBundleIconFile has the icns extension in the value. --- NSBundle+SUAdditions.m | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/NSBundle+SUAdditions.m b/NSBundle+SUAdditions.m index ff91fc60..0604569d 100644 --- a/NSBundle+SUAdditions.m +++ b/NSBundle+SUAdditions.m @@ -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