//創建壹個字符串對象數組
NSArray * array =[str components separated bystring:@ " @ "];//以@為標記輸出即可。
int count =[數組計數];
int I;
for(I = 0;我& lt數數;i=i+4)
{
printf("%i: %s\n ",I,[[array objectAtIndex:I]utf8 string]);
}
2個可變字符串類
NSMutableString * song =[[NSMutableString alloc]init];
【歌曲appendString:@《聾子萊帕德》】;
printf("%s\n ",[song utf8 string]);
ns range range =[song rangeOfString:@“聾子”];//獲取字符串“聾”的範圍
[song replace characters in range:range with string:@ " Def "];//替換
printf("%s\n ",[song utf8 string]);
[song insertString:@ " Animal by " at index:0];
printf("%s\n ",[song utf8 string]);
【歌曲發布】;
三
字典加數組運算
NSArray * keys =[@ " one two three " components separated bystring:@ " "];
NSArray * value =[@ " two Bravo a " components separated bystring:@ " "];
ns dictionary * DIC =[[ns dictionary alloc]initWithObjects:value for keys:keys];
printf("%s\n ",[[DIC description]utf8 string]);
NSString
*******************************************************************************************/
//1.NSString
/* -創建字符串的方法。
//1.創建壹個常量字符串。
NSString *astring = @ "這是壹個字符串!";
//2.創建壹個空字符串並賦值。
ns string * string =[[ns string alloc]init];
string = @ "這是壹個字符串!";
【收斂釋放】;
NSLog(@ "收斂劑:%@ ",收斂劑);