|
|
От: | XJess | |
| Дата: | 10.08.11 07:59 | ||
| Оценка: | |||
#import <Foundation/Foundation.h>
@interface Cat : NSObject
{
@private
int weight;
int birthday;
}
- (NSString *)description;
- (void) Tail;
@end#import "Cat.h"
@implementation Cat
- (id)init
{
self = [super init];
if (self) {
// Initialization code here.
weight = 65;
}
return self;
}
- (void) TailImpl
{
NSLog(@"Cat's tail");
}
- (void) Tail;
{
[self TailImpl];
}
- (NSString *)description
{
return @"Big, fat Cat";
}
@end#import <Foundation/Foundation.h>
#import "Cat.h"
@interface Cat (Crack)
- (int) weight;
@end
@implementation Cat (Crack)
- (int) weight
{
return weight;
}
@end
@interface NSObject (Crack)
- (NSString*) description;
@end
@implementation NSObject (Crack)
- (NSString*) description
{
return @"Crazy Cat";
}
@end
int main (int argc, const char * argv[])
{
@autoreleasepool
{
Cat* cat = [Cat new];
[cat Tail];
NSLog(@"%d", [cat weight]);
NSNumber* pNum = [NSNumber numberWithInt:10];
// insert code here...
NSLog(@"%@", cat.description);
}
return 0;
}Cat's tail
65
Big, fat Cat