如果有一个包含许多字符串的NSMutableArray。是否可以删除所有以"类型(音乐)"开头的对象?数组如下所示:
[0] = type(movie),name...
[1] = type(music),name...
[2] = type(movie),name...
[3] = type(movie),name...
[4] = type(music),name...
您可以使用循环删除以"type(music)"开头的对象。
NSMutableArray *array = ...;
for (NSString *string in array) {
if ([string hasPrefix:@"type(music)"]) {
[array removeObject:string];
}
}