gpt4 book ai didi

objective-c - 错误: unrecognized selector sent to class

转载 作者:行者123 更新时间:2023-12-03 09:18:28 25 4
gpt4 key购买 nike

对于 Objective C(甚至对于 OOP 而言),我完全是个菜鸟。这就是我正在尝试做的事情

AInterface.m

@implementation AInterface

- (BOOL)getParam:(NSData **)a param1:(NSData**)param1 param2:(NSData**)param2
{

//Do a bunch of things
return bool;
}

@end

AInterface.h

@interface AInterface : NSObject

- (BOOL)getParam:(NSData **)a param1:(NSData**)param1 param2:(NSData**)param2;

+ (instancetype) inst;
@end

testMain.m()

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
}

当我运行此命令时,我收到一条错误消息,提示失败:

 caught "NSInvalidArgumentException", "+[AInterface inst]: unrecognized selector sent to class 

最佳答案

尽管您在 @interface 部分声明了 +inst 方法,但您的类并未实现它,这会导致运行时错误。您需要添加实现才能使其工作,例如

@implementation AInterface
...
+ (instancetype)inst {
return [self new];
}

关于objective-c - 错误: unrecognized selector sent to class,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35278798/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com