类别

.h

@interface NSString(XXXXXX)

-(NSInteger)getLen;

@end

.m

@implementation NSString(XXXXXX)

 -(NSInteger)getLen

{

  return 0;

}

@end

////////////////////////////////////////////////////////////////////////////////////////////////////

扩展

.h

@interface ClassA

{

  NSString * a;

}

-(void)Info;

@end

.m

@interface ClassA

{

  NSString * b;

}

-(void)GetName;

@end

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

类别是对已有的某个类添加新的方法。

扩展是多新创建的类添加 变量或者方法(就是在.m文件里面进行添加)

IOS 类别与扩展的区别 (category & extensions)的更多相关文章

  1. iOS 类别和扩展(Categories和Extensions)

    分类(Category)   分类能够做到的事情主要是:即使在你不知道一个类的源码情况下,向这个类添加扩展的方法.   此外,分类能够保证你的实现类和其他的文件区分开.   1 #import “UI ...

  2. ios 类别和扩展-赵小波

    类别 @interface ClassName ( CategoryName ) // method declarations @end Category在iOS开发中使用非常频繁.尤其是在为系统类进 ...

  3. (转)iOS分类和扩展(Categories和Extensions)

    分类(Category)   分类能够做到的事情主要是:即使在你不知道一个类的源码情况下,向这个类添加扩展的方法.   此外,分类能够保证你的实现类和其他的文件区分开. #import “UIView ...

  4. iOS 类别 类扩展 简要说明

  5. [ios]objective-c中Category类别(扩展类)专题总结

    本文转载至 http://yul100887.blog.163.com/blog/static/20033613520126333344127/   objective-c类别的作用?通过类别的方式, ...

  6. 类目(category) - 类扩展(extension) 区别

    说明: 方法,属性或变量:   类别只能添加方法,不能添加属性(理论上,但可以通过runtime的关联添加). 扩展可以添加方法和实例变量或属性,实例变量默认@private类型.扩展是类别的一个特例 ...

  7. iOS类别(Category)

    iOS类别(Category)与扩展(Extension) 苹果的官方文档 Category在iOS开发中使用非常频繁.尤其是在为系统类进行拓展的时候,我们可以不用继承系统类,直接给系统类添加方法,最 ...

  8. iOS学习系列 - 扩展机制category与associative

    iOS学习系列 - 扩展机制category与associative category与associative作为objective-c的扩展机制的两个特性,category即类型,可以通过它来扩展方 ...

  9. iOS 通知中心扩展制作初步-b

    涉及的 Session 有 Creating Extensions for iOS and OS X, Part 1 Creating Extensions for iOS and OS X, Par ...

随机推荐

  1. C Primer Plus 第3章 数据和C 编程练习

    1. /* 整数上溢 */ #include <stdio.h> int main(void) { ; unsigned ; /* 无符号整数j像一个汽车里程指示表(形容的太好了,可参考& ...

  2. 解决 Ubuntu 开机 Waiting for 60 seconds more for network configuration

    sudo vim /etc/network/interfaces, 将该文件的内容修改为如下:(也就是说删掉其他的什么auto eth0.auto wlan0) auto lo iface lo in ...

  3. jQuery对象与Dom对象的相互转换

    1.jQuery对象转换为Dom对象 [index] var $d = $("#id"); ]; get(index) var $d = $("#id"); ) ...

  4. Project Euler 75:Singular integer right triangles

    题目链接 原题: It turns out that 12 cm is the smallest length of wire that can be bent to form an integer ...

  5. Apache与Tomcat整合

    Apache与Tomcat整合   一 Apache与Tomcat比较联系 apache支持静态页,tomcat支持动态的,比如servlet等. 一般使用apache+tomcat的话,apache ...

  6. 核心思想:百度网盘怎么盈利(互联网的高速更新决定了:亏钱你还有点机会,放弃连门都进不了),战略预备队 good

    百度做网盘很大程度就是为了防止别人依靠网盘做大和积累点技术储备.腾讯邮箱怎么赚钱?腾讯影音怎么赚钱?互联网的高速更新决定了,一些你看不起眼的软件很可能就会席卷整个市场,所以互联网大佬宁愿一些项目亏钱也 ...

  7. Resource is out of sync with the file system的解决办法

    在eclipse中,启动server时报此错,是因为文件系统不同步造成的,解决方法有两个: (1)选中工程,右键,选择F5(手动刷新): (2)Window->Preferences->G ...

  8. set集合_变长

    //set可变集合 //便利初始化函数分配大小 NSMutableSet *mutableSet1 = [[NSMutableSet alloc] initWithCapacity:3]; NSMut ...

  9. VC6.0下string不能用pusk_back,可用+=代替

    2013-09-11 21:14:32 在VS下运行正确的代码,拿到VC6.0下,编译出错,提示: error C2039: 'push_back' : is not a member of 'bas ...

  10. cmd修改系统时间

    time 11:15:00  修改时间 date 2015/11/25  修改日期