#import <foundation/foundation.h>int main (int argc, const char * argv []) { @autoreleasepool { nsstring *tempstr; //the string that will be split nsmutablestring * mutablestring=[[nsmutablestring alloc]initwithstring:@ "Hello, World!ni hao "]; //the character set of the split string NSCharacterSet * characterSet =[NSCharacterSet charactersetwithcharactersinstring:@ ",! "]; // Save the split string with an array NSArray *array=[mutableString COMPONENTSSEPARATEDBYCHARACTERSINSET:CHARACTERSET];&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;//Fast Enumeration method for (TeMpstr in array) { nslog ( @ "%@", TempStr); } //Enumerator Method nsenumerator * enumerator =[array objectEnumerator]; while (Tempstr=[enumerator nextobject]) { nslog (@ "%@", TempStr); } } return 0;}
This article is from the Web Learning Summary blog, so be sure to keep this source http://8947509.blog.51cto.com/8937509/1556711
Using OC to realize strtok function in C language