iPhone / iPad Development: Objective-C string into an array of access points (similar to java's split)

2010-11-11  来源:本站原创  分类:Mobile  人气:144 

In many languages such as java, ruby, python cut in both the string into an array or an interval of the array elements to form a new array of string spacing. In fact NSArray also provide this functionality.

Use-componentsSeparatedByString: to cut points NSArray. Such as:

Quote

NSString * string = @ "one: two: three";
NSArray * aArray = [string componentsSeparatedByString :@":"];

By-componentsJoinedByString: NSArray to merge and create the various elements of a new string, such as:
string = [aArray componentsJoinedByString :@","];

Thus, the above array to each element on the "" split to form a string.

相关文章