如何搜索NSMutableDictionary

Dev*_*per 1 iphone objective-c

我有一个简单的问题.如何搜索NSMutable Dictionary?例如.我有一个这样的字典:

      A1: Apple
      B1: Banana
      C1:  Cat
      D1:  Dog
      A2: Aeroplane
      B2: Bottle
      A3: Android
Run Code Online (Sandbox Code Playgroud)

现在我想搜索以字母"A"开头的所有内容(值),意味着我想搜索"Apple,Airplane和Android".我知道如何搜索数组而不是字典.请帮帮我.

ken*_*ytm 12

for (NSString* key in theDictionary) {
   if ([key hasPrefix:@"A"]) {
      // found such a key, do whatever you like e.g.
      [theNewDictionary setObject:[theDictionary objectForKey:key] forKey:key];
   }
}
Run Code Online (Sandbox Code Playgroud)