开发者

Conforming protocol privately

开发者 https://www.devze.com 2023-01-18 02:55 出处:网络
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 HiddenClas

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:

@int开发者_JAVA百科erface 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
0

精彩评论

暂无评论...
验证码 换一张
取 消