Reputation: 223
I am a complete noob when it comes to Objective C (or even for OOP for that matter). Here is what I am trying to do
@implementation AInterface
- (BOOL)getParam:(NSData **)a param1:(NSData**)param1 param2:(NSData**)param2
{
//Do a bunch of things
return bool;
}
@end
@interface AInterface : NSObject
- (BOOL)getParam:(NSData **)a param1:(NSData**)param1 param2:(NSData**)param2;
+ (instancetype) inst;
@end
int main()
{
Bool result = NO;
NSData *a = Nil;
NSData *b = Nil;
NSData *c = Nil;
result = [[AInterface inst] getParam:(NSData **)&a param1:(NSData**)&a param2:(NSData**)&b];
return result
}
When I run this though, I get an error saying failed:
caught "NSInvalidArgumentException", "+[AInterface inst]: unrecognized selector sent to class
Upvotes: 2
Views: 1581
Reputation: 1461
Your problem is that you don't have implementation of +inst
in AInterface.m
.
In your case inst
would be something like:
[[AInterface alloc] init]
but I'd just use [[AInterface alloc] init]
instead of calling inst
in the first place. Or [AInterface new]
, which stands for the same.
In general, the rest of your code is not idiomatic Objective-C.
Upvotes: 1
Reputation: 170849
Although you declared +inst method in @interface section your class does not have it implemented and that leads to runtime error. You need to add implementation to make it work, e.g.
@implementation AInterface
...
+ (instancetype)inst {
return [self new];
}
Upvotes: 4