소멸자 [free] Objc
2009.11.20 17:12 Edit
#import <stdio.h>
#import <objc/Object.h>
@interface Test : Object
-(id)init;
-(id)free;
@end
@implementation Test
- (id)init {
id obj = [super init];
printf("init method\n");
return obj;
}
- (id)free {
printf("free method\n");
return [super free];
}
@end
int main() {
id obj = [Test new];
[obj free];
return 0;
}
#import <objc/Object.h>
@interface Test : Object
-(id)init;
-(id)free;
@end
@implementation Test
- (id)init {
id obj = [super init];
printf("init method\n");
return obj;
}
- (id)free {
printf("free method\n");
return [super free];
}
@end
int main() {
id obj = [Test new];
[obj free];
return 0;
}
위의 코드는 메모리 할당 후 바로 해제하는 코드이다.
이 글과 관련된 글
- [2009/11/20] 클래스 오브젝트 (401)
- [2009/11/20] 클래스 메소드 (467)
- [2009/11/20] 가시성[접근자] (311)
- [2009/11/20] 정적 클래스 (413)
- [2009/11/20] 생성자 [constructor] (274)
- Tag :
- Objc , Obj-C , Objective-C
