是的。可以尝试这样。不需要在这里采用任何循环概念,这在有大数据时非常有用。
NSString *str=[[array1 valueForKeyPath:@"name"] componentsJoinedByString:@","];
NSLog(@"desired string:%@",str);
NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
[dict setObject:@"app" forKey:@"name"];
NSMutableDictionary *dict1 = [[NSMutableDictionary alloc]init];
[dict1 setObject:@"app1" forKey:@"name"];
NSMutableDictionary *dict2 = [[NSMutableDictionary alloc]init];
[dict2 setObject:@"app2" forKey:@"name"];
NSArray *array1 = [[NSArray alloc]initWithObjects:dict,dict1,dict2, nil];
NSString *str=[[array1 valueForKeyPath:@"name"] componentsJoinedByString:@","];
NSLog(@"desired string:%@",str);
O/P:- app,app1,app2