Created
April 24, 2009 15:42
-
-
Save ddribin/101153 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// gcc -o undefined-key undefined-key.m -framework Foundation | |
#import <Foundation/Foundation.h> | |
@interface Foo : NSObject { } | |
@end | |
@implementation Foo | |
#if 1 | |
- (id)valueForUndefinedKey:(NSString *)key | |
{ | |
NSLog(@"%@: undefined key: %@", [self className], key); | |
fprintf(stderr, "%s: undefined key: %s\n", [[self className] UTF8String], [key UTF8String]); | |
return nil; | |
} | |
#endif | |
@end | |
int main (int argc, const char * argv[]) { | |
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; | |
Foo * foo = [[[Foo alloc] init] autorelease]; | |
id value = [foo valueForKey:@"bar"]; | |
NSLog(@"value: %@", value); | |
value = [foo mutableSetValueForKey:@"bar"]; | |
NSLog(@"mutable value: %@", value); | |
[pool drain]; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment