在类中指定自己的委托,在 Interface Builder 中进行类型检查
我编写了一个 Objective-C 类,需要通知另一个类,因此我为委托定义了一个协议:
@protocol glob_protocol <NSObject>
@required
- (IBAction) call:(int) val val2:(int) val2;
@end
在我的类中,我有一个成员来存储委托:
IBOutlet id <glob_protocol> delegate;
在 Interface Builder 中连接类/实例时,没有类型检查现在。我可以作为代表连接任何班级。
有没有办法启用类型检查?我希望只有实现该协议的类/实例才能设置为委托。
感谢您的任何提示, 托斯顿.
编辑: 我刚刚检查了 UIKit 的头文件,看看是否有任何其他信息或关键字,但我没有找到任何信息或关键字。我想知道 InterfaceBuilder 从哪里获得可以将哪些实例设置为委托的信息。
I wrote an objective-C class that needs to notify another class, so i defined a protocol for a delegate:
@protocol glob_protocol <NSObject>
@required
- (IBAction) call:(int) val val2:(int) val2;
@end
In my class i have a member to store the delegate:
IBOutlet id <glob_protocol> delegate;
When connecting the classes / instances in the Interface Builder there is no type checking now. I can connect any class as a delegate.
Is there a way to enable type checking? I'd like that only classes / instances that implement the protocol can be set as delegates.
Thanks for any hints,
Torsten.
EDIT:
I just checked in the Header files of UIKit to see if there are any additional infos or keywords but i did not find any. I wonder where InterfaceBuilder got tthe information from what instances can be set as delegate.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这通常有效:
尽管这不是您想要的级别/阶段,但它效果很好,因为连接不会经常改变。
this usually works:
although that's not at the level/phase you want, it works well because connections don't change often.