Category分类
来源:互联网 发布:豆角台剧网下载软件 编辑:程序博客网 时间:2024/04/28 15:39
Student.h:
#import <Foundation/Foundation.h>@interface Student : NSObject@property(nonatomic) int no;-(void)TestStudent;@end
Student.m:
#import "Student.h"@implementation Student-(void)TestStudent{ NSLog(@"我是测试Student的方法");}@end
Student+Test.h
#import "Student.h"//()分类文件方法//Test是分类的方法名@interface Student (Test)//注意:只能扩展方法,不能添加成员变量-(void) Test2;@end@interface Student(Addtion)-(void) Test3;@end
Student+Test.m:
#import "Student+Test.h"@implementation Student (Test)-(void)Test2{ NSLog(@"我是分类方法Test2");}@end@implementation Student(Addtion)-(void)Test3{ NSLog(@"我是分类方法test3");}@end
NSString+JSON.h:
#import <Foundation/Foundation.h>@interface NSString (JSON)+(NSString *)json;@end
NSString+JSON.m:
#import "NSString+JSON.h"@implementation NSString (JSON)+(NSString *)json{ return @"{'name':'dxw','id':10}";}@end
main:
#import <Foundation/Foundation.h>#import "Student.h"#import "Student+Test.h"#import "NSString+JSON.h"int main(int argc, const char * argv[]){ @autoreleasepool { Student *stu=[[[Student alloc] init] autorelease]; [stu TestStudent]; [stu Test2]; [stu Test3]; NSLog(@"%@",[NSString json]); } return 0;}结果:
2013-08-02 15:47:57.364 Category[1322:303] 我是测试Student的方法
2013-08-02 15:47:57.366 Category[1322:303] 我是分类方法Test2
2013-08-02 15:47:57.367 Category[1322:303] 我是分类方法test3
2013-08-02 15:47:57.368 Category[1322:303] {'name':'dxw','id':10}
- Category分类
- 分类Category
- Category分类
- 分类(category)
- Category(分类)
- category 分类
- 分类:category
- 分类Category
- Objective-C分类 (category)
- OC与Category 分类
- 黑马程序员------Category:分类
- OC语言--分类(category)
- Objective-C 分类Category
- 分类(category)、协议(protocol)
- OC中的分类Category
- 038.category 分类/类别
- Category(分类)
- Category分类用法
- 如何利用OpenCV自带的haar training程序训练分类器
- VC 网络编程socket
- 关于多人物场景下遮挡关系的思考
- 发邮件相关代码
- 传智播客.Net培训-2
- Category分类
- 传智播客.Net培训-3
- QCom MSM MDP4驱动显示过程
- 嵌入式Linux
- 【摄影测量】4D的简单介绍
- HDU4565 So Easy!
- HDU 1010 Tempter of the bond
- HDU 1495 非常可乐(bfs)|POJ 3414 Pots(bfs+打印路径)
- Python 3语法小记(九) 异常 Exception