Objective C 클래스 외부에서 속성을 어떻게 설정할 수 있습니까?
MyCtlr라는 클래스가 있고 MyCtrl.h에서 다음 status
과 같은 변수를 선언했습니다 .
@interface RejectController : UIViewController{
IBOutlet UICustomLabel *lblMessage;
}
@property NSInteger status;
@end
그런 다음 다른 클래스에서 다음과 같은 특정 값으로 설정하고 싶습니다.
MyCtrl *myCtrl = [self.storyboard instantiateViewControllerWithIdentifier:@"MyCtrlIdentify"];
[myCtrl status:2]; //here triggers the error: No visible @interface for 'MyCtrl' declares the selector 'status:'
[self.navigationController pushViewController:myCtrl animated:YES];
하지만 값을 상태로 설정하려고하면 오류가 발생합니다. No visible @interface for 'MyCtrl' declares the selector 'status:'
이유를 아는 사람이 있습니까?
속성을 사용하면 접근 자 메서드가 자동으로 생성됩니다. 따라서 다음 중 하나를 수행해야합니다.
[myCtrl setStatus:2];
또는
myCtrl.status = 2;
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다