Skip to content

Commit

Permalink
Added new NSDictionary utils.
Browse files Browse the repository at this point in the history
  • Loading branch information
ldandersen committed May 9, 2005
1 parent 2a9cd98 commit c4b13ee
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Delicious Client.xcode/buzz.pbxuser
Original file line number Diff line number Diff line change
Expand Up @@ -1405,8 +1405,8 @@
6BF88AE405C4D56000D7EDBB = {
uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {1736, 20622}}";
sepNavSelRange = "{46989, 78}";
sepNavVisRect = "{{0, 18786}, {459, 186}}";
sepNavSelRange = "{47231, 0}";
sepNavVisRect = "{{0, 0}, {711, 429}}";
sepNavWindowFrame = "{{15, 269}, {750, 558}}";
};
};
Expand Down
6 changes: 4 additions & 2 deletions Delicious Client.xcode/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -889,15 +889,17 @@
fileEncoding = 4;
isa = PBXFileReference;
lastKnownFileType = sourcecode.c.h;
path = "NSDictionary+SFHFUtils.h";
name = "NSDictionary+SFHFUtils.h";
path = "Utilities/NSDictionary+SFHFUtils.h";
refType = 4;
sourceTree = "<group>";
};
6B6B69DF082B3C97003DFA07 = {
fileEncoding = 4;
isa = PBXFileReference;
lastKnownFileType = sourcecode.c.objc;
path = "NSDictionary+SFHFUtils.m";
name = "NSDictionary+SFHFUtils.m";
path = "Utilities/NSDictionary+SFHFUtils.m";
refType = 4;
sourceTree = "<group>";
};
Expand Down
16 changes: 16 additions & 0 deletions Utilities/NSDictionary+SFHFUtils.h
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
36 changes: 36 additions & 0 deletions Utilities/NSDictionary+SFHFUtils.m
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

0 comments on commit c4b13ee

Please sign in to comment.