I have developed simple app that stores name and id of student into NSMutableArray by using NSDictionary and I want to get names only after stored in NSMutableArray and than store into NSArray
Here my simple code
NSDictionary *student1 = [NSDictionary dictionaryWithObjectsAndKeys:
@"key1", @"id",
@"Joe", @"name",
nil];
NSMutableArray *array = [NSMutableArray arrayWithObjects:student1, nil];
please help me how to solve this.
Try this:
NSDictionary *student1 = [NSDictionary dictionaryWithObjectsAndKeys:
@"key1", @"id",
@"Joe", @"name",
nil];
NSMutableArray *array = [NSMutableArray arrayWithObjects:student1, nil];
NSMutableArray *mArr = [[NSMutableArray alloc]init];
for (NSDictionary *student in array) {
[mArr addObject:[student objectForKey:@"name"]];
}
NSArray *arr = mArr;
NSLog(@"%@",arr); //OUTPUT: (Joe)