具有 20 万个条目的 NSDictionary 查找表 - iPhone
我有一个简单的查找表,它由以下结构组成:
int | 给定一个 int 的字符串
- ,我想返回一个字符串。但是我必须使用查找表,因为 int 和字符串之间没有相关性。
在 iPhone 上用 Objective-C 实现这一点最有效、最快的方法是什么?
例如
// 但是 200k 的值会不会加载时间太长并且占用太多内存? NSString *value = [lookupTable objectForKey:[NSNumber numberWithInt:key]]
I have a simple lookup table, which consists of the following structure:
int | string
- given an int, I want to return a string. However I have to use a lookup table as there is no correlation between the int and the string.
What is the most efficient and fastest way to implement this on the iPhone in Objective-C?
E.g.
// However will 200k values take too long to load and take up too much memory?
NSString *value = [lookupTable objectForKey:[NSNumber numberWithInt:key]]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在不知道字符串有多大的情况下,您几乎肯定应该查看 coredata 来查找此类内容。它可以很好地处理这些数字,并且可以保持较低的内存占用。
这里有一个非常好的coredata教程,当然还有大量 Apple 文档
Without knowing how large your strings are, you should almost certainly be looking at coredata for this sort of thing. It'll work a treat for those sort of numbers and will keep your memory footprint low.
There's quite a nice coredata tutorial here and of course copious Apple documentation