diff options
author | thomasvl@gmail.com <thomasvl@gmail.com@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2009-01-09 20:34:30 +0000 |
---|---|---|
committer | thomasvl@gmail.com <thomasvl@gmail.com@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2009-01-09 20:34:30 +0000 |
commit | 4fd103b5de98d2f469b982677ea389e7ee7d64b3 (patch) | |
tree | d0eb379fdc78996bc2e201515d26c7521d1fc8dc /Foundation/GTMNSAppleEventDescriptor+Foundation.m | |
parent | 84d1232477f398339e48ea504c45048e9328ef9b (diff) |
- turned off _debug framework support in tests since we now capture a lot more
in log validation.
- Added GTM_SUPPORT_GC for controlling the inclusion of GC related code.
- If you are using GTMUnitTestDevLog, it also tries to capture logs from
NSAssert.
- Added GTM_FOREACH_OBJECT/GTM_FOREACH_KEY that uses NSEnumerator and
objectEnumerator/keyEnumerator on 10.4, but on 10.5+/iPhone uses
FastEnumeration.
- GTMNSWorkspace+Running gives a variety of ways of determining the attributes
of running processes.
Diffstat (limited to 'Foundation/GTMNSAppleEventDescriptor+Foundation.m')
-rw-r--r-- | Foundation/GTMNSAppleEventDescriptor+Foundation.m | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/Foundation/GTMNSAppleEventDescriptor+Foundation.m b/Foundation/GTMNSAppleEventDescriptor+Foundation.m index d0c26ec..b355607 100644 --- a/Foundation/GTMNSAppleEventDescriptor+Foundation.m +++ b/Foundation/GTMNSAppleEventDescriptor+Foundation.m @@ -100,15 +100,22 @@ static NSMutableDictionary *gTypeMap = nil; NSMutableDictionary *dictionary = [NSMutableDictionary dictionary]; NSAppleEventDescriptor *userRecord = [self descriptorForKeyword:keyASUserRecordFields]; if (userRecord) { - NSEnumerator *userItems = [[userRecord gtm_arrayValue] objectEnumerator]; - NSString *key; - while ((key = [userItems nextObject])) { - NSString *value = [userItems nextObject]; - if (!value) { - _GTMDevLog(@"Got a key %@ with no value in %@", key, userItems); - return nil; + NSArray *userItems = [userRecord gtm_arrayValue]; + NSString *key = nil; + NSString *item; + GTM_FOREACH_OBJECT(item, userItems) { + if (key) { + // Save the pair and reset our state + [dictionary setObject:item forKey:key]; + key = nil; + } else { + // Save it for the next pair + key = item; } - [dictionary setObject:value forKey:key]; + } + if (key) { + _GTMDevLog(@"Got a key %@ with no value in %@", key, userItems); + return nil; } } else { NSUInteger count = [self numberOfItems]; @@ -291,10 +298,9 @@ static NSMutableDictionary *gTypeMap = nil; } - (NSAppleEventDescriptor*)gtm_appleEventDescriptor { - NSEnumerator* keys = [self keyEnumerator]; Class keyClass = nil; id key = nil; - while ((key = [keys nextObject])) { + GTM_FOREACH_KEY(key, self) { if (!keyClass) { if ([key isKindOfClass:[GTMFourCharCode class]]) { keyClass = [GTMFourCharCode class]; @@ -314,8 +320,7 @@ static NSMutableDictionary *gTypeMap = nil; NSAppleEventDescriptor *desc = [NSAppleEventDescriptor recordDescriptor]; if ([keyClass isEqual:[NSString class]]) { NSMutableArray *array = [NSMutableArray arrayWithCapacity:[self count] * 2]; - keys = [self keyEnumerator]; - while ((key = [keys nextObject])) { + GTM_FOREACH_KEY(key, self) { [array addObject:key]; [array addObject:[self objectForKey:key]]; } @@ -325,8 +330,7 @@ static NSMutableDictionary *gTypeMap = nil; } [desc setDescriptor:userRecord forKeyword:keyASUserRecordFields]; } else { - keys = [self keyEnumerator]; - while ((key = [keys nextObject])) { + GTM_FOREACH_KEY(key, self) { id value = [self objectForKey:key]; NSAppleEventDescriptor *valDesc = [value gtm_appleEventDescriptor]; if (!valDesc) { |