码迷,mamicode.com
首页 > 其他好文 > 详细

The differences between Class Extension and Header File 类扩展与头文件的区别

时间:2015-08-05 18:06:08      阅读:97      评论:0      收藏:0      [点我收藏+]

标签:

.

 

As the name suggests, they extend the class. A class continuation is another name. The class extension is commonly used to declare private methods and properties. You want the class extension to be visible to the @implementation, and not in the header file.

Types and methods in the header file are generally intended to be public -- available to any client.

Example: The property declared in the class extension will not be visible/accessible to clients who #import the header, but it will be usable by the @implementationbecause the @implementation can see the declarations of the class extension.

So this can be used to emulate restricted access for your ivars and methods. This is useful because ObjC methods and properties cannot be specified as private/protected/public (e.g. using @public).

Class extensions differ from categories primarily because extensions may declare storage (e.g. properties which will produce backing ivars).

 

.

The differences between Class Extension and Header File 类扩展与头文件的区别

标签:

原文地址:http://www.cnblogs.com/forzhaokang/p/4705210.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!