gpt4 book ai didi

ios - 无法识别的实例已发送至 - 委托(delegate)

转载 作者:行者123 更新时间:2023-11-29 03:59:42 26 4
gpt4 key购买 nike

我创建了一个静态库,用于我的其他 iOS 应用程序项目。它的工作方式是应用程序项目在我的静态库中实现协议(protocol)并调用静态库中的方法。然后静态库在调用 View 之上呈现一个 View 。代码如下:

委托(delegate)中主类的MyFile.h文件:

@protocol MyHandlerDelegate <NSObject>

- (void)infoRetrieved:(BOOL)success;

@end

@interface MyFile : UIViewController
{
id <MyHandlerDelegate> delegate;
}

@property (retain) id delegate;

MyFile.m 包含:

- (void)showRewards
{
[[[self delegate] view] addSubview:view1];
}

现在,当我仅使用一个按钮创建一个虚拟应用程序时,效果很好,并且静态库成功地在调用 View 之上呈现了一个 View 。现在我需要在开源游戏 TweetJump(基于 Cocos2D 构建)中实现此功能。在 highscores 类中,我包含了头文件并实现了委托(delegate)。在实现文件中,我调用了以下代码:

MyFile *mf = [[MyFile alloc] init];
[mf setDelegate:self];
[mf showRewards];

为了您的考虑,我主持了高分类(class) - HeaderImplementation .执行上述方法时出现的错误是:

2013-04-16 23:54:42.658 tweejump[11502:c07] +[Highscore view]:无法识别的选择器发送到类 0xecc08
2013-04-16 23:54:42.661 tweejump[11502:c07] *** 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“+[Highscore view]:无法识别的选择器发送到类 0xecc08”

我知道这是一个乏味的问题。将非常感谢您的帮助。谢谢

最佳答案

它告诉您 Highscore 类没有 View 方法。您的协议(protocol)规定委托(delegate)只需是 NSObject 即可,无需更具体。

关于ios - 无法识别的实例已发送至 - 委托(delegate),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16048842/

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