Skip to content

Instantly share code, notes, and snippets.

@mdippery
Created October 18, 2012 20:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdippery/48e3ad94ac3a7fdc2627 to your computer and use it in GitHub Desktop.
Save mdippery/48e3ad94ac3a7fdc2627 to your computer and use it in GitHub Desktop.
Non-string keys in NSDictionary
#import <Foundation/Foundation.h>
int main(int argc, char **argv)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSNumber *key = [NSNumber numberWithInteger:10];
NSString *val = @"Ten";
NSMutableDictionary *d = [NSMutableDictionary dictionary];
[d setObject:val forKey:key]; // This will compile fine
[d setValue:val forKey:key]; // This will cause a compiler error
[pool release];
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment