iOS Learning Road of Objective-c (iii)--nsmutablestring

Source: Internet
Author: User

  1. Nsmutablestring creation of mutable strings

    1     nsmutablestring *string1 = [[nsmutablestring alloc] init]; 2     // string2 Object methods are created, String3 are created by class methods 3     nsmutablestring *string2 = [[Nsmutablestring alloc] initwithcapacity:0]; 4     nsmutablestring *string3 = [nsmutablestring stringwithcapacity:0];

  2. Adding a String

    1Nsmutablestring *string=[[Nsmutablestring alloc] init];2     //-(void) appendString: (NSString *) astring;3     //function: Added after a string without creating a new string4[stringAppendString:@"bei Jing Ying nin"];5NSLog (@"%@",string);6     //-(void) insertstring: (NSString *) astring Atindex: (nsuinteger) loc;7     //role: Inserting a string at a location in a string8[stringInsertstring:@"Huan"Atindex:8];9NSLog (@"%@",string);

  3. Deletion of strings

    Nsmutablestring *string=[[Nsmutablestring alloc] init]; [stringAppendString:@"bei Jing Huan Ying Nin"]; NSLog (@"%@",string); //-(void) Deletecharactersinrange: (nsrange) range; //role: Deletion of stringsNsrange range = {1,5}; [stringDeletecharactersinrange:range]; NSLog (@"%@",string);

iOS Learning Road of Objective-c (iii)--nsmutablestring

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.