Objective-c Category(类别)
category是Objective-c里面最常用的功能之一。
category可以为已经存在的类增加方法,而不需要增加一个子类。
类别接口的标准语法格式如下:
NSString* string1 = @"http://www.csdn.net";NSString* string2 = @"Pixar";if( [string1 isURL] ) NSLog(@"string1 is a URL");else NSLog(@"string1 is not a URL");if( [string2 isURL] ) NSLog(@"string2 is a URL");else NSLog(@"string2 is not a URL");