-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ldandersen
committed
May 9, 2005
1 parent
2a9cd98
commit c4b13ee
Showing
4 changed files
with
58 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// NSDictionary+SFHFUtils.h | ||
// Delicious Client | ||
// | ||
// Created by Laurence Andersen on Thu May 05 2005. | ||
// Copyright (c) 2005 __MyCompanyName__. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
|
||
@interface NSDictionary (SFHFUtils) | ||
|
||
- (id) initWithObjects: (NSArray *) objects keyName: (NSString *) keyName; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// NSDictionary+SFHFUtils.m | ||
// Delicious Client | ||
// | ||
// Created by Laurence Andersen on Thu May 05 2005. | ||
// Copyright (c) 2005 Sci-Fi Hi-Fi. All rights reserved. | ||
// | ||
|
||
#import "NSDictionary+SFHFUtils.h" | ||
|
||
|
||
@implementation NSDictionary (SFHFUtils) | ||
|
||
- (id) initWithObjects: (NSArray *) objects keyName: (NSString *) keyName { | ||
if (self = [super init]) { | ||
NSEnumerator *objectEnumerator = [objects objectEnumerator]; | ||
id currentKey; | ||
id currentValue; | ||
NSMutableArray *keys = [[NSMutableArray alloc] init]; | ||
NSMutableArray *values = [[NSMutableArray alloc] init]; | ||
|
||
while ((currentValue = [objectEnumerator nextObject]) != nil) { | ||
if ((currentKey = [currentValue valueForKey: keyName]) != nil) { | ||
[keys addObject: currentKey]; | ||
[values addObject: currentValue]; | ||
} | ||
} | ||
|
||
return [self initWithObjects: [values autorelease] forKeys: [keys autorelease]]; | ||
} | ||
else { | ||
return nil; | ||
} | ||
} | ||
|
||
@end |