How To Manage NSMutableDictionary And NSMutableArray

//create the dictionary
NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init];

//add keyed data
[dictionary setObject:@”Object One” forKey:@”1″];
[dictionary setObject:@”Object Two” forKey:@”2″];
[dictionary setObject:@”Object Three” forKey:@”3″];

//write out Object Three to the log
NSLog(@”%@”, [dictionary objectForKey:@”3″]);

//release the dictionary
[dictionary release];

//create the mutablearray
NSMutableArray *arrayOfObjects = [[NSMutableArray alloc] init];
[arrayOfObjects addObject:@”Object One”];
[arrayOfObjects addObject:@”Object Two”];
[arrayOfObjects addObject:@”Object Three”];
[arrayOfObjects addObject:@”Object Four”];
[arrayOfObjects addObject:@”Object Five”];

//write out Object to the log
NSLog(@”Object = %@”, [arrayOfObjects objectAtIndex:object no]);


Discover more from mycodetips

Subscribe to get the latest posts sent to your email.

Discover more from mycodetips

Subscribe now to keep reading and get access to the full archive.

Continue reading

Scroll to Top