-5
在Objective-C有可能那样做:Swift如何获取字典中键值的数量?
NSString *sectionTitle = [animalSectionTitles objectAtIndex:section];
NSArray *sectionAnimals = [animals objectForKey:sectionTitle];
return [sectionAnimals count];
如果动物是[字符串:字符串]字典 但是在斯威夫特3没有对字典的方法objectForKey(String:)
或任何类似的或者我可以“找不到它
使用'动物[sectionTitle]' – Venkat
你试过'动物[sectionTitle]'? – TawaNicolas
请阅读:[Swift Language Guide:Swift Tour](https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/GuidedTour.html#//apple_ref/doc/uid/TP40014097- CH2-ID1)。即使在Objective-C中,您也可以(也应该)使用密钥和索引订阅。 – vadian