NSString *path = [[NSBundle mainBundle] pathForResource:@"mainPlistFile" ofType:@"plist"];
//path has path for main plist.
NSDictionary *dictionary=[NSDictionary dictionaryWithContentOfFile: path];
NSArray *listbook = [dictionary objectForKey:@"listbook"];
for (NSDictionary *item in listbook) {
if ([[item objectForKey:@"bid"] isEqualToString yourNSStringWithBidToSearch]) {
//now item is the desired dictionary, you can get values by using objectForKey
//or write it to a file like below.
[item writeToFile:pathToSaveNewPlist automatically:NO];
break;
}
}
最初に NSString pathToSaveNewPlist と yourNSStringWithBidToSearch を作成する必要があることを覚えておいてください。それはあなたに任せます。
だからあなたは質問を編集しました: 検索する入札値の NSStrings を持つ NSArray bidsToSearch があると仮定しましょう:
NSMutableArray *targetListbook = [[NSMutableArrray alloc] init]];
NSDictionary *dictionary=[NSDictionary dictionaryWithContentOfFile:[[NSBundle mainBundle] pathForResource:@"mainPlistFile" ofType:@"plist"]];
for (NSDictionary *item in [dictionary objectForKey:@"listbook"])
if ([bidsToSearch containsObject:[item objectForKey:@"bid"]])
[targetListbook addObject:item];
[@{listbook:targetListbook} writeToFile:pathToSaveNewPlist automatically:NO];