Objective-C
vim の ft は objc
#import <stdio.h>
#import <objc/Object.h>
@interface HelloObj : Object
{
char* name;
}
- (id) initWithName: (char*)yourname;
- (void) hello: (char*)yourname;
- (void) hello;
@end
//-----
@implementation HelloObj
- (id) initWithName: (char*)yourname {
// self->name = yourname; // same
name = yourname;
return self;
}
- (void) hello: (char*)yourname {
printf("Hello World! %s\n", yourname);
}
- (void) hello {
[self hello:name];
}
@end
int main() {
id obj = [[HelloObj alloc] init];
// id obj = [HelloObj new];
[obj hello:"Satoshi"];
[obj free];
id obj2 = [[HelloObj alloc] initWithName:"Taro"];
[obj hello];
[obj2 free];
return 0;
}無駄にクラス使った Hello World!
ところで、iconv が \n を含んだ文字列でエラー吐くのはなんなんだろう。