이것 저것, 안 팍으로 골치 아픈일들이 내 주위를 차지하고 있어서...
당장의 해결책도 중요하지만 그 보다는 왜 그러한 일들이 발생했는지, 어떻게 하면 사전에 방지할 수 있는지 생각해본다.
그러기 위해서는 큰 틀을 바꾸어야 할 것 같은데...
그게 고민이다.
instance 변수는 기본적으로 class 외부에서 access 할 수 없음
+ 로 시작 시 class method
인수의 개수와 label이 다를 경우 method명이 같더라도 상이한 method로 처리됨
*Example
-----------------------------------------------
(void) setValue : (int) : (int)(void) setValue : (int) label : (int)
-----------------------------------------------Objective C method 기본 반환형은 id type
instance method : 생성된 instance에서만 호출 가능
class method : instance가 존재하지 않아도 호출 가능
@ implementation 으로 시작하여 @ end로 끝남
Method 호출 방법
instance method : [instance name of method : parameter]
class method : [name of class name of method : parameter]
*Example
-----------------------------------------------
# import <stdio.h>
#import <objc/Object.h>
@interface Test : Object
-(void) method;
@end
@implementation Test
-(void) method {
printf ( "Hello world!\ n");
}
@end
intmain () {
id obj = [Test alloc];
[obj method];
return 0;
}-----------------------------------------------
최근 덧글