NSArray *ArtistNames = [RawData componentsMatchedByRegex:regEx1];
NSCharacterSet *doNotWant = [NSCharacterSet characterSetWithCharactersInString:@"'"];
ArtistNames = [[ArtistNames componentsSeparatedByCharactersInSet: doNotWant] componentsJoinedByString: @"'"];
此刻我的代码基本上我不能使用它,因为ArtistNames是一个数组而不是字符串,我将如何通过它?
答案 0 :(得分:7)
我认为你是以错误的顺序调用你的方法。尝试将其分成多个语句。
// 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];
答案 1 :(得分:1)
为什么不绕过数组并自己创建第二个数组呢?