Last active
February 23, 2024 17:22
-
-
Save itod/323373d468d19b572a56fdb4a15d9f66 to your computer and use it in GitHub Desktop.
ObjC OpenSUSE
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> | |
// sudo zyp in gcc-c++ gcc-objc gnustep-base-devel | |
// gcc -lobjc -lgnustep-base -fconstant-string-class=NSConstantString -fobjc-exceptions Foo.m -o Foo | |
// https://web.archive.org/web/20120816003625/http://blog.lyxite.com:80/2008/01/compile-objective-c-programs-using-gcc.html | |
@interface Foo : NSObject | |
@end | |
@implementation Foo | |
- (id)init { | |
self = [super init]; | |
if (self) { | |
NSLog(@"init\n"); | |
} | |
return self; | |
} | |
- (void)dealloc { | |
printf("dealloc\n"); | |
[super dealloc]; | |
} | |
- (void)foo { | |
printf("foo\n"); | |
} | |
int main(int argc, char const *argv[]) { | |
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; { | |
id obj = [Foo new]; | |
[obj foo]; | |
[obj release]; | |
printf("hi\n"); | |
} [pool release]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment