Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个存储用户配置文件集合的 NSMutableDictionary,我将如何获取最后添加的配置文件?
NSDictionary 不提供开箱即用的此类服务。随意从中派生另一个类,并将最后添加的对象的键存储在 ivar 中。
NSDictionary对象是无序的(通常在任何语言中,字典都是无序的)哈希表。我建议使用 anNSArray代替。您可以使用 NSDate 时间戳作为键,但是您必须遍历每个键才能找到最新的键,这可能会很慢。
NSDictionary
NSArray