내가 클래스 메소드 선언 : 같은 클래스에서호출 방법 계층 구조
+(int)widthScaled:(UIImage *)image maximumHeight:(int)max{
int width = 0;
width = (image.size.width - (((image.size.height - max)*100)/image.size.height)*image.size.width)/100;
return width;
}
를, 내가 인스턴스 메서드 다음과 같이 선언한다
- (void)generarVistas{
if(...){
...
}else{
for(...){
...
//I need to put the class method here but if I call the class method like this, don't recognize
int variable = [[self class] widthScaled:image maximumHeight:max];
...
}
}
내가 클래스 메소드를 넣어 시도 인스턴스 메소드에서는 작동하지만 작동하지 않습니다. 클래스 메서드를 인식하기 위해 어떤 컨텍스트를 나타내야합니까?
: 클래스가 FooClass 경우,이 양식을 사용합니다. ...? – Kampai
UIViewController – PlugInBoy
클래스의 정적 변수를'-viewDidLoad' 또는'-init' 메소드에 할당 한 다음이 변수를 사용하여 인스턴스 메소드를 호출하십시오 – Kampai