클래스 내부 및 외부에서 호출해야하는 함수가있는 클래스가 있습니다. 다음 코드는 잘 작동하지만 궁금한데 거기에 하나만있는 방법이 있나요? - 및 +가있는 두 메서드 대신 lowerKeyboard
메서드가 있습니까? 클래스 내에서 클래스예를 들어 동일한 메소드와 클래스 메소드. 가능한?
내부에서 메소드를 호출 할 때 나는 오류 unrecognized selector sent to instance
를 얻을 수 있습니다 난 그냥 + 방법을하겠습니다 경우 클래스 외부에서
-(void)someOtherMethod
{
UIBarButtonItem *infoButtonItem=[[UIBarButtonItem alloc]initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(lowerKeyboard)];
}
:
를[myClass lowerKeyboard];
myClass를
-(void)lowerKeyboard
{
//do something
}
+(void)lowerKeyboard
{
//do the exact same thing
}
[클래스와 인스턴스 메서드의 차이점은 무엇입니까?] (http://stackoverflow.com/questions/1053592/what-is-the-difference-between-class-and-instance-methods) –
@DavidCaunt 당신은 나쁜 것을 깨는 것에서 tod처럼 보입니다! 차이점을 묻지 않고, 차이점을 알고 있습니다. 내 질문은 두 가지를 결합하는 방법을 묻습니다. – Segev
아니, 그는 나처럼 보입니다! –