1
我有含有值的plist如下搜索最接近的值一个NSArray
1,23,45,67,88,99,34,26,50,28 - 等,等
我是访问的plist如下:
NSString *path2 = [[NSBundle mainBundle] pathForResource:@"Fractions" ofType:@"plist"];
pickerData2 =[[NSDictionary alloc]initWithContentsOfFile:path2];
selectorKeysFractions = [[NSArray alloc] initWithArray:[pickerData2 allKeys]];
现在我要搜索值的plist靠近用户例如输入
这样一个值,如果用户在文本字段我想找到进入69来自plist的值67并且读取t他为该字典项目的关键值
我如何找到最近的值?
任何帮助将不胜感激
嗨本感谢您的建议上面 - 假设数组排序什么是二进制搜索组成? – superllanboy
http://en.wikipedia.org/w/index.php?title=Binary_search_algorithm –
被警告,这可以使你的应用程序超慢,如果你有很多值...(但它肯定是最简单的方法来编程!) –