"Good Programmer's note sharing" obj-c category

Source: Internet
Author: User

<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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.