Created
January 21, 2014 06:13
-
-
Save rgoulter/8535166 to your computer and use it in GitHub Desktop.
Objective C, playing with nil, #1.
This file contains 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
#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; | |
} |
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
As one might expect, the above does nothing. (Nothing exciting, anyway).
If foo is instead replaced with the [[Foo alloc] init] bit, then it does output "hello" as one might expect.