类目举例
#import "ViewController.h"
#import "NSString+test.h"
NSString *sss=@"123"; NSString *ss=[sss subStringWithString:@"456"]; NSLog(@"%@",ss);
//NSString+test.h
#import <Foundation/Foundation.h> @interface NSString (test) -(NSString *) subStringWithString:(NSString *)str; @end
//NSString+test.m
#import "NSString+test.h" @implementation NSString (test) -(NSString *)subStringWithString:(NSString *)str { NSString *str1=[[NSString alloc]initWithFormat:@"%@--%@",self,str]; return str1; } @end