Created
June 23, 2010 20:53
-
-
Save patrick99e99/450532 to your computer and use it in GitHub Desktop.
This file contains 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
#import <Cocoa/Cocoa.h> | |
@interface Dog : NSObject { | |
NSString *name; | |
NSString *color; | |
NSString *hair; | |
NSString *size; | |
NSString *breed; | |
} | |
@property (nonatomic, copy) NSString *name; | |
@property (nonatomic, copy) NSString *color; | |
@property (nonatomic, copy) NSString *size; | |
@property (nonatomic, copy) NSString *hair; | |
@property (nonatomic, copy) NSString *breed; | |
- (void) description; | |
- (void) speak:(NSString *)bark; | |
@end |
This file contains 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
#import "Dog.h" | |
@implementation Dog | |
@synthesize name, hair,size, breed, color; | |
- (void) description | |
{ | |
NSLog(@"%@ is a %@ %@ %@ haired %@.", name, size, color, hair, | |
breed); | |
} | |
- (void) speak:(NSString *)bark | |
{ | |
NSLog(@"%@ says \"%@\"!", name, bark); | |
} | |
@end |
This file contains 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
main.m: | |
#import <Foundation/Foundation.h> | |
#import "Dog.h" | |
int main (int argc, const char * argv[]) { | |
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; | |
Dog *puppy = [[Dog alloc] init]; | |
[puppy setName:@"Lucky"]; | |
[puppy setColor:@"black"]; | |
[puppy setSize:@"big"]; | |
[puppy setBreed:@"Australian Shepherd"]; | |
[puppy setHair:@"long"]; | |
[puppy description]; | |
[puppy speak:@"Woof"]; | |
[puppy speak:@"Squeaky Wheel"]; | |
[pool drain]; | |
return 0; | |
} | |
[Session started at 2009-05-05 10:04:50 -0700.] | |
2009-05-05 10:04:50.819 pet2[5646:10b] Lucky is a big black long haired | |
Australian Shepherd. | |
2009-05-05 10:04:50.824 pet2[5646:10b] Lucky says "Woof"! | |
2009-05-05 10:04:50.824 pet2[5646:10b] Lucky says "Squeaky Wheel"! | |
The Debugger has exited with status 0. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment