//第一种:利用NSDictionary的allKeys(allValues)方法。
NSArray *array = @[@"2016-10-1",@"2016-10-9",
@"2016-10-9",@"2016-10-9",@"2016-12-25",
@"2016-12-25",@"2016-12-25",
@"2016-12-25",@"2016-12-25"];
NSMutableDictionary *dic = [[NSMutableDictionary alloc]initWithCapacity:0];
for (NSString *str in array) {
[dic setValue:str forKey:str];
}
NSLog(@"%@",[dic allKeys]);<pre name="code" class="html">//打印结果
(
"2016-12-25",
"2016-10-1",
"2016-10-9"
)<pre name="code" class="html">
//第一种:利用NSDictionary的allKeys(allValues)方法。