类别

.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. python 判断操作系统类型

    #!/bin/python # import platform def TestPlatform(): print ("----------Operation System--------- ...

  2. Mysql数据库int(1)和tinyint(1)的区别&&扩展阅读

    转自:http://blog.csdn.net/phpwish/article/details/7845921 今天看项目的数据库结构设计,发现一个奇怪的地方. `xxx_detail`   `del ...

  3. 转一个distinct用法,很有帮助

    转一个distinct用法,很有帮助 (2011-12-01 15:18:11) 转载▼ 标签: 杂谈 分类: mysql复制 在使用mysql时,有时需要查询出某个字段不重复的记录,虽然mysql提 ...

  4. 单例模式与Android

    http://blog.csdn.net/ljianhui/article/details/29275655 多线程下的单例模式是不安全的 Android中的单例模式 Android中存在着大量的单例 ...

  5. python 利用smtp发送邮件,html格式

    def send_mail(to_list, sub, context):#sentmail to the maillist ''' to_list: 发送给谁 sub: 主题 context: 内容 ...

  6. ArcGIS 10.1 for Desktop新特性之地理标记照片

    转自:http://blog.csdn.net/esrichinacd/article/details/7730825 地理标记照片是指带有地理位置信息的照片,通常通过内置GPS的数码相机或智能手机拍 ...

  7. NPOI基础入门(旧版本)

    1.常用的类与方法 工作本HSSFWorkbook 构造方法,无参表示创建一个新的工作本,可以接收一个流用于打开一个现有的工作本 方法CreateSheet(索引):创建指定索引的sheet对象 方法 ...

  8. Spring与Hibernate整合

    Spring与Struts2整合的目的: 让Spring管理Action Spring整合Hinernate的目的: --管理SessionFactory(单例的),数据源 --声明式事务管理 1.首 ...

  9. printf left justify

    http://www.lemoda.net/c/printf-left-justify/index.html This example program demonstrates how to left ...

  10. myeclipse2014破解版本链接

    myeclipse2014破解版本下载链接 http://www.my-eclipse.cn/#download myeclipse2014破解版本汉化链接 https://blog.my-eclip ...