code_junkie

How can I access specific subsets of a large NSDictionary in Cocoa?

Nov 13th, 2011
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. @interface NSDictionary (dictionaryForClass)
  2.  
  3. -(NSMutableDictionary *) dictionaryWithObjectsKindOfClass:(Class)myClass;
  4.  
  5. @end
  6.  
  7. @implementation NSDictionary (dictionaryForClass)
  8.  
  9. -(NSMutableDictionary *) dictionaryWithObjectsKindOfClass:(Class)myClass;
  10. {
  11. NSMutableDictionary *ret = [[[NSMutableDictionary alloc] init] autorelease];
  12.  
  13. for (id object in self) {
  14. if ([object isKindOfClass:myClass]) {
  15. [ret addObject:object];
  16. }
  17. }
  18. return ret;
  19.  
  20. }
  21.  
  22. @end
Add Comment
Please, Sign In to add comment