搜索plist文件中已存在的图像(xcode)

时间:2012-11-12 13:04:16

标签: ios xcode uiimageview plist uisearchbar

我是一名新的iPhone开发人员,我目前正在开展一个项目。 * 首先我有一个包含图像的plist文件。这些图像有自己的ID。对于前者image1的id为'100',image2的id为'101'。我的应用中也有一个搜索栏。当我输入一个数字(id)到搜索栏时,我想从plist文件中获取图像,并在UIImageView中显示它。对于ex。我在搜索栏中输入“100”。其ID为“100”的图像将显示在UIImageView中。 * 实际上我不知道如何用xcode做到这一点。

1 个答案:

答案 0 :(得分:0)

这是从plist获取这些图像的方法。在获得数组后,您可以使用NSPredicate或从数组中搜索以获得所需的结果。

  NSString *path = [[NSBundle mainBundle] pathForResource:@"EventAddress" ofType:@"plist"]; 
  NSMutableDictionary *myDictionary = [[NSMutableDictionary alloc] initWithContentsOfFile:path];
  NSArray* allmyKeys = [myDictionary  allValues];