ITCategory-NSBundle (new): Added category that adds
authorJoseph Spiros <joseph.spiros@ithinksw.com>
Wed, 16 Feb 2005 04:27:11 +0000 (04:27 +0000)
committerJoseph Spiros <joseph.spiros@ithinksw.com>
Wed, 16 Feb 2005 04:27:11 +0000 (04:27 +0000)
+bundleForFrameworkWithIdentifier: class method to NSBundle.

ITCategory-NSBundle.h [new file with mode: 0644]
ITCategory-NSBundle.m [new file with mode: 0644]
ITFoundation.xcode/project.pbxproj

diff --git a/ITCategory-NSBundle.h b/ITCategory-NSBundle.h
new file mode 100644 (file)
index 0000000..7211858
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ *     ITFoundation
+ *     ITCategory-NSBundle.h
+ *
+ *     Copyright (c) 2005 by iThink Software.
+ *     All Rights Reserved.
+ *
+ *     $Id$
+ *
+ */
+
+#import <Cocoa/Cocoa.h>
+
+@interface NSBundle (ITCategory)
+
++ (NSBundle *)bundleForFrameworkWithIdentifier:(NSString *)frameworkIdentifier;
+
+@end
diff --git a/ITCategory-NSBundle.m b/ITCategory-NSBundle.m
new file mode 100644 (file)
index 0000000..c7acbcc
--- /dev/null
@@ -0,0 +1,38 @@
+#import "ITCategory-NSBundle.h"
+
+@implementation NSBundle (ITCategory)
+
++ (NSBundle *)bundleForFrameworkWithIdentifier:(NSString *)frameworkIdentifier {
+       NSMutableArray *frameworksPaths = [NSMutableArray array];
+       NSArray *libraryPaths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,NSAllDomainsMask,YES);
+       NSEnumerator *libraryEnumerator = [libraryPaths objectEnumerator];
+       NSString *libraryPath;
+       
+       [frameworksPaths addObject:[[self mainBundle] privateFrameworksPath]];
+       [frameworksPaths addObject:[[self mainBundle] sharedFrameworksPath]];
+       
+       while (libraryPath = [libraryEnumerator nextObject]) {
+               [frameworksPaths addObject:[libraryPath stringByAppendingPathComponent:@"Frameworks"]];
+               [frameworksPaths addObject:[libraryPath stringByAppendingPathComponent:@"PrivateFrameworks"]];
+       }
+       
+       NSEnumerator *frameworksEnumerator = [frameworksPaths objectEnumerator];
+       NSString *frameworksPath;
+       
+       while (frameworksPath = [frameworksEnumerator nextObject]) {
+               NSArray *frameworkPaths = [NSBundle pathsForResourcesOfType:@"framework" inDirectory:frameworksPath];
+               NSEnumerator *frameworkEnumerator = [frameworkPaths objectEnumerator];
+               NSString *frameworkPath;
+               
+               while (frameworkPath = [frameworkEnumerator nextObject]) {
+                       NSBundle *frameworkBundle = [NSBundle bundleWithPath:frameworkPath];
+                       if (frameworkBundle && [[frameworkBundle bundleIdentifier] isEqualToString:frameworkIdentifier]) {
+                               return frameworkBundle;
+                       }
+               }
+       }
+       
+       return nil;
+}
+
+@end
index e7e51ca..f32054d 100755 (executable)
 //2A4
                2AB93A2C057059DC007E748F = {
                        children = (
 //2A4
                2AB93A2C057059DC007E748F = {
                        children = (
+                               7C2D93BD07C2FD6700A487A9,
+                               7C2D93BE07C2FD6700A487A9,
                                7C058DF7072F10530082E1E9,
                                7C058DF8072F10530082E1E9,
                                2AB93A3005705A0C007E748F,
                                7C058DF7072F10530082E1E9,
                                7C058DF8072F10530082E1E9,
                                2AB93A3005705A0C007E748F,
                        settings = {
                        };
                };
                        settings = {
                        };
                };
+               7C2D93BD07C2FD6700A487A9 = {
+                       fileEncoding = 4;
+                       isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
+                       path = "ITCategory-NSBundle.h";
+                       refType = 4;
+                       sourceTree = "<group>";
+               };
+               7C2D93BE07C2FD6700A487A9 = {
+                       fileEncoding = 4;
+                       isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.objc;
+                       path = "ITCategory-NSBundle.m";
+                       refType = 4;
+                       sourceTree = "<group>";
+               };
+               7C2D93BF07C2FD6700A487A9 = {
+                       fileRef = 7C2D93BD07C2FD6700A487A9;
+                       isa = PBXBuildFile;
+                       settings = {
+                       };
+               };
+               7C2D93C007C2FD6700A487A9 = {
+                       fileRef = 7C2D93BE07C2FD6700A487A9;
+                       isa = PBXBuildFile;
+                       settings = {
+                       };
+               };
                7C97DC2C05B614300013E85F = {
                        fileEncoding = 4;
                        isa = PBXFileReference;
                7C97DC2C05B614300013E85F = {
                        fileEncoding = 4;
                        isa = PBXFileReference;
                                3D97138A05D9FD6B0033607F,
                                376AF4DF06597CA900F0979E,
                                7C058DF9072F10530082E1E9,
                                3D97138A05D9FD6B0033607F,
                                376AF4DF06597CA900F0979E,
                                7C058DF9072F10530082E1E9,
+                               7C2D93BF07C2FD6700A487A9,
                        );
                        isa = PBXHeadersBuildPhase;
                        runOnlyForDeploymentPostprocessing = 0;
                        );
                        isa = PBXHeadersBuildPhase;
                        runOnlyForDeploymentPostprocessing = 0;
                                3D97138B05D9FD6B0033607F,
                                376AF4E006597CA900F0979E,
                                7C058DFA072F10530082E1E9,
                                3D97138B05D9FD6B0033607F,
                                376AF4E006597CA900F0979E,
                                7C058DFA072F10530082E1E9,
+                               7C2D93C007C2FD6700A487A9,
                        );
                        isa = PBXSourcesBuildPhase;
                        runOnlyForDeploymentPostprocessing = 0;
                        );
                        isa = PBXSourcesBuildPhase;
                        runOnlyForDeploymentPostprocessing = 0;