Objective-C中受保护的方法 [英] Protected methods in Objective-C

查看:68
本文介绍了Objective-C中受保护的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与Objective-C中的受保护方法等效吗? 我想定义仅派生类可以调用/实现的方法.

What is the equivalent to protected methods in Objective-C? I want to define methods which only the derived classes may call/implement.

推荐答案

您都不能将受保护的方法声明为私有. Objective-C的动态性质使其无法实现方法的访问控制. (您可以通过大量操作 修改编译器或运行时,速度会受到严重影响,但是出于明显的原因,这样做没有完成.)

You can neither declare a method protected or private. Objective-C's dynamic nature makes it impossible to implement access controls for methods. (You could do it by heavily modifying the compiler or runtime, at a severe speed penalty, but for obvious reasons this is not done.)

来自来源.

这篇关于Objective-C中受保护的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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