iOS中四种实例变量的范围类型@private@protected@public@package
2013-06-25 14:23
323 查看
Directive | Meaning |
@private | The instance variable is accessible only within the class that declares it. |
@protected | 实例变量只能被声明它的类访问 The instance variable is accessible within the class that declares it and within classes that inherit it. All instance variables without an explicit scope directive have @protected scope. 实例变量能被声明它的类和子类访问,所有没有显式制定范围的实例变量都是@protected |
@public | The instance variable is accessible everywhere. 实例变量可以被在任何地方访问。 |
@package | Using the modern runtime, an @package instance variable has @public scope inside the executable image that implements the class, but acts like@private outside.使用modern运行时,一个@package实例变量在实现这个类的可执行文件镜像中实际上是@public的,但是在外面就是@private【runtime需要再看一下苹果文档Runtime Programming Guide】 The @package scope for Objective-C instance variables is analogous toprivate_extern for C variables and functions. Any code outside the class implementation’s image that tries to use the instance variable gets a link error. Objective-C中的@package与C语言中变量和函数的private_extern类似。任何在实现类的镜像之外的代码想使用这个实例变量都会引发link error This scope is most useful for instance variables in framework classes, where @private may be too restrictive but @protected or @public too permissive. 这个类型最常用于框架类的实例变量,使用@private太限制,使用@protected或者@public又太开放 |
相关文章推荐
- iOS中四种实例变量的范围类型@private@protected@public@package
- iOS中四种实例变量的范围类型@private@protected@public@package
- iOS中四种实例变量的范围类型@private@protected@public@package
- iOS中四种实例变量的范围类型@private@protected@public@package
- iOS中四种实例变量的范围类型@private@protected@public@package
- iOS中四种实例变量的范围类型@private@protected@public@package
- oc 中四种实例变量的范围类型@private@protected@public@package
- IOS中的四种变量修饰关键字 @private @protected @public @package
- iOS面试题(2.类变量的@protected,@private,@public,@package声明各有什么含义)拓展:常用框架和第三方框架
- IOS基础——实例变量四种范围类型
- IOS的变量修饰词@public 、@protected、@package、@private,简称 4P
- 一个小程序让你懂得:public,protected,friendly,private的引用变量范围
- 【iOS Tips】007-@protected,@private,@public,@package
- c++ public, protected, private成员变量,成员函数继承和访问规则实例代码
- iOS 面试题~@private,@protected,@public,@package详解及使用
- IOS基础--@private|@protected| @public|@package
- iOS @private,@protected,@public,@package详解及使用
- iOS中四种实例变量的范围类…
- public,private,protected,internal 的作用范围
- PHP访问修饰符public , private ,protected 访问权限实例详解