I know you could add all the keys to an array and add it to one side of the dictionary but I'm curious how you can add or insert a value at a certain point in the dictionary. The way i have it now it I believe it just keeps overwriting the last entries to make room for the new one:
NSMutableDictionary *bookmarks = [[NSMutableDictionary alloc] init];
NSString *keyA = @"Stanford University";
NSString *keyB = @"Apple";
NSString *keyC = @"cs193p.com";
NSString *keyD = @"Stanford on iTunes";
NSString *keyE = @"Stanford Mail";
NSString *surlA = @"http://www.stanford.edu";
NSString *surlB = @"http://www.apple.com";
NSString *surlC = @"http://www.cs193p.stanford.edu";
NSString *surlD = @"http://www.itunes.stanford.edu";
NSString *surlE = @"http://www.stanfordshop.com";
NSURL *urlA;
urlA = [NSURL URLWithString:surlA];
NSURL *urlB;
urlA = [NSURL URLWithString:@"http://www.apple.com"];
[bookmarks setValue:urlA forKey: keyA];
[bookmarks setObject:urlB forKey: keyB];
//[bookmarks setObject:urlC forKey: keyC];
//[bookmarks setObject:urlD forKey: keyD];
//[bookmarks setObject:urlE forKey: keyE];
NSLog(@"%@", [bookmarks valueForKey:keyA]);
heres the output:
2010-01-13 11:08:51.484 assignment_1b[6035:a0f] http://www.apple.com