<a href= "http://www.goodprogrammer.org/" target= "blank" >ios training </A>------My obj-c language notes, looking forward to communicating with you!
1, category can be divided into a class of implementation of a number of different files (c + + Java can not be implemented).
2, to the existing class dynamic, static add some methods in;
3, can only extend the function, the message, cannot extend the field, the variable;
4, category naming specification: to extend the class name + extension variables. [HM];
5, in the new version of Xcode Add category, to choose obj-c file-->category-->file (extension variable)-->class (extension class name);
#import "nsstring+reversestring.h"@implementationnsstring (reversestring)- (ID) reversestring{Nsuinteger len= [self length];//get the length of the stringnsmutablestring*STR = [nsmutablestring Stringwithcapacity:len];//request Len Size space while(len>0) {Unichar C= [self Characteratindex:--len];//take character from behindNSLog (@"C is%c", c); NSString*s = [NSString stringWithFormat:@"%c", c];//Initialize string s with the character taken[str appendstring:s];//Add to Str } returnstr;} @end
"Good Programmer's note sharing" obj-c category