Can directly copy the code can be combined with output to see the results deepen memory
Create a mutable string
nsmutablestring * ms1 = [[nsmutablestring alloc]init];
//Can be created by using the class method
nsmutablestring * MS2 = [nsmutablestring string];
Create a mutable string using the Format method
MS1 = [nsmutablestring stringwithformat:@ "%d", 12];
//Specify initialization size Create a mutable string (create a string of length 10)
MS1 = [[nsmutablestring alloc]initwithcapacity:10];
//Create a variable string with another specified string
MS2 = [nsmutablestring stringwithstring:ms1];
#pragma mark Stitching string
Stitching strings
[Ms1 appendstring:@ "345"];
[Ms1 appendstring:@ "welcome You"];
//Format stitching
[Ms1 appendformat:@ "%@", @ "come to Huludao"];
NSLog (@ "%@", MS1);
#pragma mark Insert String
//Inserts a string at the specified location
[Ms1 insertstring:@ "brother" atindex:3];//location
#pragma mark Replacement
Substitutes the supplied string for the contents of the specified range for the original character
[Ms1 replacecharactersinrange:nsmakerange (0, 3) withstring:@ "B elder brother"];
NSLog (@ "%@", MS1);
#pragma mark to delete a string
[Ms1 Deletecharactersinrange:nsmakerange (3,5)];
NSLog (@ "%@", MS1);
#pragma mark Setup Content
Re-set string contents
[Ms1 setstring:@ "root all ills"];
NSLog (@ "%@", MS1);
All operations for iOS variable strings