Created
March 23, 2013 18:17
-
-
Save semireg/5228813 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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