嗨,我有以下格式的 plist
我想根据它们的类别 ID 对这些书进行排序。我有一个包含所有类别 id 的数组“TotalCategory”(例如:cat1,cat2 ..),我想打开下面的 plist 并检查每本书及其类别 id 是否匹配。如果我拥有的类别 id 是与给定书籍的类别 ID 匹配,然后我想将该类别 ID 和书籍 ID(出价)添加到新字典中。有可能吗?
NSDictionary *booksPlist = [[NSDictionary alloc] initWithContentsOfFile:path];
NSArray *categoryId=[[booksPlist objectForKey:@"catlist"]valueForKey:@"cid"];
NSLog(@"%@",categoryId);
// getting category list
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *allBooksPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"Allbooks.plist"];
NSDictionary *allBookPlist=[[NSDictionary alloc]initWithContentsOfFile:allBooksPath];
NSArray *bookid=[[allBookPlist objectForKey:@"listbook"]valueForKey:@"bid"];
NSString *s=[[[allBookPlist objectForKey:@"listbook"]objectForKey:@"cate" ]valueForKey:@"categories"]; //// this line shows exception
NSLog(@"%@",s);
/// 我想要这个 ::: 我想和我一起检查类别 id 和每本书中的类别 id,如果匹配,然后检索该书 id(出价)就是它