---------------------A string split instance---------------------
NSString * ptr = @ "I am a Man";
Return a string as a whole as a split condition to a nsarray non-variable group
Nsarray * array = [ptr componentsseparatedbystring:@ ""];
If modified, convert Nsarray to Nsmutablearray
Nsmutablearray * array1 = [Nsmutablearray Arraywitharray:array];
To split a character in a string as a segmentation condition
Nsarray * array2 = [ptr componentsseparatedbycharactersinset:[nscharacterset charactersetwithcharactersinstring:@ "," ]];
"Character Set"
Nscharacterset This is a character set.
Converts a string into a character set
[Nscharacterset charactersetwithcharactersinstring:@ ","]
---------------------string Concatenation instance---------------------
NSString * str = [array componentsjoinedbystring:@ ""];
If the split condition appears at the beginning or the end, an empty string @ "" will appear, and if not, it will need to be converted to nsmutablestring to process the empty string.
FUNC1: [Array1 removeobject:@ ""];
Find empty string to delete directly
Func2:for (id obj in array1) {
if ([obj length] = = 0)
The length of the empty string is 0
if ([obj isequaltostring:@ ""])
Compare to empty string (string is not = = comparison, use function)
}
In OC, there are 3 ways to say,
NSString *str=[nsstring initwithformat:@ "%@,%@", a , b]; NSString *str=[a stringbyappendingstring:b]; NSString *str=[string stringbyappendingformat:@ "%@,%@", a , b];
iOS Development--string segmentation, stitching