标签:
1-OC和Java中迭代
NSSet *set1 = [NSSet setWithObjects:@"one", @"two", @"two", nil]; NSEnumerator *e = [set1 objectEnumerator]; NSString *s; while((s = [e nextObject]) != nil) { NSLog(@"%@", s); }
2-数组转集合
NSArray *arr2 = @[@"one", @"one", @"two", @"tow"]; NSSet *set = [NSSet setWithArray:arr2]; NSLog(@"%@", set);
3-Map
NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:@"IOS", @"1", @"Android", @"2", @"cocos2d-x", @"3", nil]; NSLog(@"%@", dic); NSArray *keys = @[@"1", @"2", @"3", @"3"]; NSArray *values = @[@"Android", @"iOS", @"cocos2dx", @"wp8"]; NSDictionary *dc3 = [NSDictionary dictionaryWithObjects:values forKeys:keys]; NSLog(@"%@", dc3);
标签:
原文地址:http://www.cnblogs.com/awebing/p/5657695.html