views:

304

answers:

1
NSMutableDictionary *bookmarks = [NSMutableDictionary dictionary];

[bookmarks setObject:[NSURL URLWithString:(NSString *) @"http://stanford.edu"] forKey:
@"Stanford University"];
[bookmarks setObject:[NSURL URLWithString:(NSString *) @"http://apple.com"] forKey:
@"Apple"];
[bookmarks setObject:[NSURL URLWithString:(NSString *) @"http://itunes.stanford.edu"] forKey:
@"Stanford on iTunesU"];
[bookmarks setObject:[NSURL URLWithString:(NSString *) @"http://stanfordshop.com"] forKey:
@"Stanford Mall"];

NSEnumerator *browser = [bookmarks keyEnumerator];
id each;
NSURL *url;
while ((each = [browser nextObject])) {
url = [bookmarks objectForKey:(NSString *)each];
NSLog('%@'", url);

Greetings..., first question here. I realize Stanford's iPhone programming stuff has been beat to death (I'm sure). I'm just having a little trouble finding out how I would print the keys with the URLs. I also can't figure out how to only print keys that start with Stanford. I know it's a method of NSString though.

Thanks.

+3  A: 
for (NSString * key in [bookmarks allKeys])
{
  if ([key hasPrefix:@"Stanford"])
  {
    NSLog(key);
  }
}
Marco Mustapic
Thanks for the help.
nullArray