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]);

tips & tricks

Join 7,719 other subscribers

interview questions


Algorithm Android Android Studio API APP Programming Apps blogging Browser CheatSheets Code Config CSS DATABASE dsa error Features HTML HTML5 IDE installation Interview Questions IOS iPhone javascript Mac objective-c OneDrive OS Placeholder Programming quicktips SDK SEO Settings SMO SQL swift swiftUI Teams Tips & Tricks Tools UI Web Wordpress Xcode


Archives

Discover more from CODE t!ps

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

Continue reading