NSArray *ArtistNames = [RawData componentsMatchedByRegex:regEx1];
NSCharacterSet *doNotWant = [NSCharacterSet characterSetWithCharactersInString:@"'"];
ArtistNames = [[ArtistNames componentsSeparatedByCharactersInSet: doNotWant] componentsJoinedByString: @"'"];
那就是我的代码,现在基本上我不能使用它,因为ArtistNames是一个数组而不是字符串,我将如何处理呢?
最佳答案
我认为您在以错误的顺序调用方法。尝试将其分成多个语句。
// The separator should be some string of characters guaranteed to not be in any of the strings in the array.
#define SEPARATOR @"---***---"
NSArray *artistNames = [RawData componentsMatchedByRegex:regEx1];
NSString *doNotWant = @"'"
NSString *combinedNames = [artistNames componentsJoinedByString:SEPARATOR];
combinedNames = [combinedNames stringByReplacingOccurrencesOfString:doNotWant withString:@""];
artistNames = [combinedNames componentsSeparatedByString:SEPARATOR];