法一:
NSMutableDictionary *dic = [NSMutableDictionary dictionary];
for (NSNumber *number in arr) {
[dic setObject:number forKey:number];
}
NSLog(@"[dic allValues] %@",[dic allValues]);
// 打印结果
Simona_Test_1
法二:
NSArray *arr = @[@1,@2,@1];
NSSet *set = [NSSet setWithArray:arr];
NSLog(@"[dic allValues] %@",[set allObjects]);
// 打印结果:
Simona_Test_2
网友评论