I'm having trouble calling a class method from a View Controller. The class method takes a BOOL as input. Xcode allows me to call it without the parameter (which obviously crashes) but complains when I pass the parameter.
Here is the relevant code:
// 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
If more code is needed let me know, but this seems like it should be straightforward enough. I've looked through a bunch of "no known class method for selector" questions but most of them are either typos or calling an instance method.
I think its because your header class has the method without the parameter in it. This is what you have in your .h file:
+(BOOL)askForLocationAccess;
Change it to:
+(BOOL)askForLocationAccess:(BOOL)ask;