* ITCarbonSupport.h
*
* Utility functions to convert between FourCharCodes/OSTypes/ResTypes and
- * NSStrings.
+ * NSStrings. These only call through to the methods implemented by
+ * the ITFoundationCategory on NSString, and those methods are recommended
+ * for all new projects needing this functionality.
*
* Copyright (c) 2005 by iThink Software.
* All Rights Reserved.
#import "ITCarbonSupport.h"
+#import "ITCategory-NSString.h"
NSString *NSStringFromFourCharCode(unsigned long code) {
- return [NSString stringWithFormat:@"%.4s", &code];
+ return [NSString stringWithFourCharCode:code];
}
unsigned long FourCharCodeFromNSString(NSString *string) {
- const unsigned char *c_s = [string UTF8String];
- unsigned long tmp = *c_s++;
- tmp <<= 8;
- tmp |= *c_s++;
- tmp <<= 8;
- tmp |= *c_s++;
- tmp <<= 8;
- return tmp |= *c_s++;
+ return [string fourCharCode];
}
\ No newline at end of file
+++ /dev/null
-/*
- * ITFoundation
- * ITCategory-NSArray.h
- *
- * Copyright (c) 2005 by iThink Software.
- * All Rights Reserved.
- *
- * $Id$
- *
- */
-
-#import <Foundation/Foundation.h>
-
-@interface NSArray (ITFoundationCategory)
-
-- (NSArray *)objectsForKey:(NSString *)key;
-- (BOOL)containsString:(NSString *)string;
-
-@end
\ No newline at end of file
+++ /dev/null
-#import "ITCategory-NSArray.h"
-
-@implementation NSArray (ITFoundationCategory)
-
-- (NSArray *)objectsForKey:(NSString *)key {
- NSMutableArray *array = [[[NSMutableArray alloc] initWithCapacity:[self count]] autorelease];
- NSEnumerator *enumerator = [self objectEnumerator];
- id anItem;
-
- while ( (anItem = [enumerator nextObject]) ) {
-
- id itemObject = [anItem objectForKey:key];
-
- if ( itemObject ) {
- [array addObject:itemObject];
- } else {
- [array addObject:[NSNull null]];
- }
- }
-
- return array;
-}
-
-- (BOOL)containsString:(NSString *)string {
- NSEnumerator *enumerator = [self objectEnumerator];
- id anItem;
- BOOL result = NO;
-
- while ( (anItem = [enumerator nextObject]) ) {
-
- if ( [anItem isEqual:string] ) {
- result = YES;
- }
- }
-
- return result;
-}
-
-@end
\ No newline at end of file
[frameworksPaths addObject:[[self mainBundle] privateFrameworksPath]];
[frameworksPaths addObject:[[self mainBundle] sharedFrameworksPath]];
- while (libraryPath = [libraryEnumerator nextObject]) {
+ while ((libraryPath = [libraryEnumerator nextObject])) {
[frameworksPaths addObject:[libraryPath stringByAppendingPathComponent:@"Frameworks"]];
[frameworksPaths addObject:[libraryPath stringByAppendingPathComponent:@"PrivateFrameworks"]];
}
NSEnumerator *frameworksEnumerator = [frameworksPaths objectEnumerator];
NSString *frameworksPath;
- while (frameworksPath = [frameworksEnumerator nextObject]) {
+ while ((frameworksPath = [frameworksEnumerator nextObject])) {
NSArray *frameworkPaths = [NSBundle pathsForResourcesOfType:@"framework" inDirectory:frameworksPath];
NSEnumerator *frameworkEnumerator = [frameworkPaths objectEnumerator];
NSString *frameworkPath;
- while (frameworkPath = [frameworkEnumerator nextObject]) {
+ while ((frameworkPath = [frameworkEnumerator nextObject])) {
NSBundle *frameworkBundle = [NSBundle bundleWithPath:frameworkPath];
if (frameworkBundle && [[frameworkBundle bundleIdentifier] isEqualToString:frameworkIdentifier]) {
return frameworkBundle;
--- /dev/null
+/*
+ * ITFoundation
+ * ITCategory-NSString.h
+ *
+ * Copyright (c) 2005 by iThink Software.
+ * All Rights Reserved.
+ *
+ * $Id$
+ *
+ */
+
+#import <Foundation/Foundation.h>
+
+@interface NSString (ITFoundationCategory)
+
++ (id)stringWithFourCharCode:(unsigned long)fourCharCode;
+
+- (id)initWithFourCharCode:(unsigned long)fourCharCode;
+- (unsigned long)fourCharCode;
+
+@end
\ No newline at end of file
--- /dev/null
+#import "ITCategory-NSString.h"
+
+@implementation NSString (ITFoundationCategory)
+
++ (id)stringWithFourCharCode:(unsigned long)fourCharCode {
+ return [[[self alloc] initWithFourCharCode:fourCharCode] autorelease];
+}
+
+- (id)initWithFourCharCode:(unsigned long)fourCharCode {
+ return [self initWithFormat:@"%.4s", &fourCharCode];
+}
+
+- (unsigned long)fourCharCode {
+ const unsigned char *c_s = [self UTF8String];
+ unsigned long tmp = *c_s++;
+ tmp <<= 8;
+ tmp |= *c_s++;
+ tmp <<= 8;
+ tmp |= *c_s++;
+ tmp <<= 8;
+ return tmp |= *c_s++;
+}
+
+@end
\ No newline at end of file
#import <ITFoundation/ITCategory-NSObject.h>
#import <ITFoundation/ITCategory-NSProxy.h>
-#import <ITFoundation/ITCategory-NSArray.h>
+#import <ITFoundation/ITCategory-NSString.h>
#import <ITFoundation/ITCategory-NSBundle.h>
\ No newline at end of file
7C058DF8072F10530082E1E9,
7CB02EB407D049BB00959EA0,
7CB02EB507D049BB00959EA0,
- 2AB93A3005705A0C007E748F,
- 2AB93A3105705A0C007E748F,
+ 7C0462070801DC3700433407,
+ 7C0462080801DC3700433407,
7C2D93BD07C2FD6700A487A9,
7C2D93BE07C2FD6700A487A9,
);
refType = 4;
sourceTree = "<group>";
};
- 2AB93A3005705A0C007E748F = {
- fileEncoding = 4;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- path = "ITCategory-NSArray.h";
- refType = 4;
- sourceTree = "<group>";
- };
- 2AB93A3105705A0C007E748F = {
- fileEncoding = 4;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.objc;
- path = "ITCategory-NSArray.m";
- refType = 4;
- sourceTree = "<group>";
- };
- 2AB93A3205705A0C007E748F = {
- fileRef = 2AB93A3005705A0C007E748F;
- isa = PBXBuildFile;
- settings = {
- ATTRIBUTES = (
- Public,
- );
- };
- };
- 2AB93A3305705A0C007E748F = {
- fileRef = 2AB93A3105705A0C007E748F;
- isa = PBXBuildFile;
- settings = {
- };
- };
//2A0
//2A1
//2A2
//7C2
//7C3
//7C4
+ 7C0462070801DC3700433407 = {
+ fileEncoding = 4;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = "ITCategory-NSString.h";
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 7C0462080801DC3700433407 = {
+ fileEncoding = 4;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.objc;
+ path = "ITCategory-NSString.m";
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 7C0462090801DC3700433407 = {
+ fileRef = 7C0462070801DC3700433407;
+ isa = PBXBuildFile;
+ settings = {
+ ATTRIBUTES = (
+ Public,
+ );
+ };
+ };
+ 7C04620A0801DC3700433407 = {
+ fileRef = 7C0462080801DC3700433407;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
7C058DF7072F10530082E1E9 = {
fileEncoding = 4;
isa = PBXFileReference;
8DC2EF510486A6940098B216,
7CA50D7E054E7C600074E1D9,
7CA50B31054E77A00074E1D9,
- 2AB93A3205705A0C007E748F,
7C97DC2E05B614300013E85F,
3D97137F05D9FBF40033607F,
7C058DF9072F10530082E1E9,
7C2D93BF07C2FD6700A487A9,
7CB02EB607D049BB00959EA0,
+ 7C0462090801DC3700433407,
);
isa = PBXHeadersBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
buildActionMask = 2147483647;
files = (
7CA50B32054E77A00074E1D9,
- 2AB93A3305705A0C007E748F,
7C97DC2F05B614300013E85F,
3D97138105D9FBFA0033607F,
7C058DFA072F10530082E1E9,
7C2D93C007C2FD6700A487A9,
7CB02EB707D049BB00959EA0,
+ 7C04620A0801DC3700433407,
);
isa = PBXSourcesBuildPhase;
runOnlyForDeploymentPostprocessing = 0;