NSArray *ArtistNames = [RawData componentsMatchedByRegex:regEx1];
NSCharacterSet *doNotWant = [NSCharacterSet characterSetWithCharactersInString:@"'"];
ArtistNames = [[ArtistNames co开发者_StackOverflow社区mponentsSeparatedByCharactersInSet: doNotWant] componentsJoinedByString: @"'"];
Thats my code at the moment basically i cannot use it as ArtistNames is a array not a string, how would i get past this ?
I think you're calling your methods in the wrong order. Try breaking it into multiple statements.
// 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];
Why not just loop over the array and create the second array yourself?
精彩评论