Skip to content

Instantly share code, notes, and snippets.

@itod
Last active February 23, 2024 17:22
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 itod/323373d468d19b572a56fdb4a15d9f66 to your computer and use it in GitHub Desktop.
Save itod/323373d468d19b572a56fdb4a15d9f66 to your computer and use it in GitHub Desktop.
ObjC OpenSUSE
#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