Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想将从服务器接收到的长字符串拆分为几个子字符串。单独的字符是不同的。
是否有方法的示例代码:componentsSeparatedByCharactersInSet?或者我可以问一个简单的代码将“A~B^C”拆分为“A”、“B”和“C”吗?
试试这个
NSString *str = @"A~B^C"; NSArray *arr = [str componentsSeparatedByCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@"^~"]]; NSLog(@"%@", arr);