更新时间:2023-12-06 17:07:34
NSSet
是为了保存你的情况。使用:
NSSet
is to save you in this case. Use:
NSSet *set = [NSSet setWithArray:duplicateArray];
NSArray *uniqueArray = [set allObjects];
避免使用循环,因为如果你有更多的对象循环是一个消耗过程。你可以直接使用 NSSet
,它肯定会有效。
Avoid using loop for this because if you have more object loop is a consuming process. You can directly use NSSet
and it will work for sure.