ObjectiveC:DefaultClassTemplate
Objective-C의 클래스의 기본 형태는 Foundation.h
의 NSObject를 상속받는다.
Header file
#import <Foundation/Foundation.h>
@interface TestClass : NSObject
{
@private
int _x;
int _y;
}
- (void) setAttributeWithX: (int) x andY: (int) y;
- (int) getAttributeX;
- (int) getAttributeY;
@end
Source file
#import "header file path"
@implementation TestClass
// constructor
- (id) init
{
if (self = [super init]) {
// init member ...
}
return self;
}
// destructor
- (void) dealloc
{
// release member ...
[super dealloc];
}
- (void) setAttributeWithX: (int) x andY: (int) y
{
_x = x;
_y = y;
}
- (int) getAttributeX
{
return _x;
}
- (int) getAttributeY
{
return _y;
}
@end