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);
我意识到斯坦福的 iPhone 编程东西已经被打败了(我敢肯定)。我只是在找出如何使用 URL 打印密钥时遇到了一些麻烦。我也不知道如何只打印以斯坦福开头的密钥。我知道这是 NSString 的一种方法。