Skip to content

Instantly share code, notes, and snippets.

@semireg
Created March 23, 2013 18:17
Show Gist options
  • Select an option

  • Save semireg/5228813 to your computer and use it in GitHub Desktop.

Select an option

Save semireg/5228813 to your computer and use it in GitHub Desktop.
int main(int argc, char *argv[])
{
//XYZPerson *person = [[XYZPerson alloc] init];
XYZPerson *person = [XYZPerson person];
if(person)
{
NSLog(@"Person is alive: %@", person);
[person sayHello];
}else{
NSLog(@"No person, sorry!");
}
//XYZShoutingPerson *shoutingPerson = [XYZShoutingPerson person];
return NSApplicationMain(argc, (const char **)argv);
}
//
// XYZPerson.h
#import <Foundation/Foundation.h>
@interface XYZPerson : NSObject
+ (id)person;
- (void)sayHello;
- (void)saySomething:(NSString *)greeting;
@end
//
// XYZPerson.m
#import "XYZPerson.h"
@implementation XYZPerson
+ (id)person
{
return [[self alloc] init];
}
- (void)sayHello {
[self saySomething:@"Hello World!"];
}
- (void)saySomething:(NSString *)greeting
{
NSLog(@"%@", greeting);
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment