0
View Controller에서 클래스 메서드를 호출하는 데 문제가 있습니다. 클래스 메소드는 BOOL을 입력으로 사용합니다. Xcode는 매개 변수 (분명히 충돌 함)없이 매개 변수를 호출 할 수있게하지만 매개 변수를 전달할 때 불평합니다.매개 변수가있는 클래스 메서드를 호출 할 수 없습니다.
다음은 관련 코드입니다 :
// RLI.h
@interface RLI : NSObject <CLLocationManagerDelegate>
...
+(BOOL)askForLocationAccess;
end
// RLI.m
@implementation RLI
...
+(BOOL)askForLocationAccess:(BOOL)ask {
...
return answer;
}
end
// CLOnboardingViewController.m
@implementation CLOnboardingViewController
...
-(IBAction)allowGPSAccess:(id)sender {
// NSLog(@"%@", [sender currentTitle]);
BOOL ask = [[sender currentTitle] isEqualToString:gpsLabel];
[RLI askForLocationAccess:YES]; // No known class method for selector 'askForLocationAccess:'
[RLI askForLocationAccess]; // no complaint but crashes with "unrecognized selector sent to a class"
[RLI askForLocationAccess:ask]; // what I intend to do
...
}
end
더 많은 코드가 필요하면 알려 주시기하지만 충분히 간단합니다 같은이 보인다. 내가 "선택기에 대한 알려진 클래스 메서드"무리를 통해 봤지만 그들 중 대부분은 오타 또는 인스턴스 메서드를 호출 중 하나입니다.
나는 내가 그 시도하지만 분명히하지 않았다 생각했다. 나는 그것이 단순해야만한다는 것을 알았다! 감사! –