标签:sel 技术 loading span pre 类别 width log lazy
类别的创建
integer.h
@interface integer : NSObject @property int integer; @end
integer.m
@implementation integer @end
类别
integer+display.h
integer+display.m
#import <Cocoa/Cocoa.h> #import "integer.h" NS_ASSUME_NONNULL_BEGIN // 类别 没有成员变量 @interface integer(display) //原有类名(类别名) -(void)show; -(void)add:(integer*)other; -(void)sub:(integer*)other; -(void)mul:(integer*)other; -(void)div:(integer*)other; @end
#import "integer+display.h" @implementation integer(display) -(void)show { // NSLog(@"hello world"); NSLog(@"%i",self.integer); } -(void)add:(integer*)other { self.integer+=other.integer; } -(void)sub:(integer*)other { self.integer-=other.integer; } -(void)mul:(integer*)other { self.integer*=other.integer; } -(void)div:(integer*)other { if(other.integer!=0) { self.integer/=other.integer; } } @end
标签:sel 技术 loading span pre 类别 width log lazy
原文地址:https://www.cnblogs.com/zhangqing979797/p/13205530.html