私下协商协议 [英] Conforming protocol privately

查看:128
本文介绍了私下协商协议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法隐藏来自最终用户的协议符合?我将尝试详细描述我想要的。我有类让我们称之为 EndUserClass ,它符合一些协议,让我们说 HiddenClassDelegate 和我想从最终用户隐藏的协议。代码如下所示:

Is there any way to hide protocol conforming from an end user? I'll try to describe in details what I want. I have class let's call it EndUserClass which conforms some protocol let's say HiddenClassDelegate and this protocol I'd like to hide from end user. The code looks like as it follows:

@interface EndUserClass : NSObject  <HiddenClassDelegate>
{
  // .....
}   

@end

并且我想使用以下声明保持相同的功能:

and I want to keep the same functionality with the following declaration:

@interface EndUserClass : NSObject  
{
  // .....
}   

@end

有没有办法私下符合协议?我知道我可以在类声明中跳过委托,但它给出了我不想要的编译器警告

Is there any way to conform the protocol privately? I know that I can skip delegate in class declaration but it gives compiler warning which I don't want to have

推荐答案

通过在实现文件中声明自定义类类别来实现:

You can do that by declaring custom class category in implementation file:

// .m file
@interface EndUserClass() <HiddenClassDelegate>

@end

这篇关于私下协商协议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆