Skip to content

Instantly share code, notes, and snippets.

@rgoulter
Created January 21, 2014 06:13
Show Gist options
  • Save rgoulter/8535166 to your computer and use it in GitHub Desktop.
Save rgoulter/8535166 to your computer and use it in GitHub Desktop.
Objective C, playing with nil, #1.
#import <stdio.h>
#import <Foundation/Foundation.h>
@interface Foo : NSObject
- (void)foo;
@end
@implementation Foo
- (void) foo {
printf("hello\n");
}
@end
int main( int argc, const char *argv[] ) {
Foo * foo = nil; //[[Foo alloc] init];
[foo foo]; // Does nothing. Duh.
return 0;
}
@rgoulter
Copy link
Author

Need the -lobjc argument to compile, btw.
$ gcc -lobjc <filename.m>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment