Skip to content

Instantly share code, notes, and snippets.

@komamitsu
Created April 19, 2013 09:55
Show Gist options
  • Select an option

  • Save komamitsu/5419340 to your computer and use it in GitHub Desktop.

Select an option

Save komamitsu/5419340 to your computer and use it in GitHub Desktop.
Objective-C small sample codes
#import "Foundation/Foundation.h"
#import "User.h"
int main(void) {
User *foo = [[User alloc] init];
foo.name = @"Komamitsu";
foo.age = 123;
NSLog(@"%@", [foo hello:@"Bye"]);
return 0;
}
#import "Foundation/Foundation.h"
@interface User : NSObject
- (NSString*)hello:(NSString*)msg;
@property(copy) NSString *name;
@property int age;
@end
#import "User.h"
@implementation User
@synthesize age;
@synthesize name;
- (NSString*)hello:(NSString*)msg {
return [NSString stringWithFormat: @"Hello, my name is %@. %@\n", self.name, msg];
}
@end
@komamitsu

Copy link
Copy Markdown
Author

$ clang -Wall -lobjc -framework Foundation -fobjc-gc-only main.m User.m

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