嗨,我在 xcode 中创建了一个 plist(newfile->resourses->property list
像这样),我尝试将一个添加NSDictionary
到该 plist 但它没有添加,请帮助我这是我的代码
-(IBAction)Add:(id)sender {
_pdfbookmark = [NSMutableArray arrayWithArray:[[NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"pdfBookmarksdata" ofType:@"plist"]] objectForKey:_bookID]];
NSMutableDictionary *bookmark = [NSMutableDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"pdfBookmarksdata" ofType:@"plist"]];
if(self.bookmarkIndicator.tintColor == [UIColor blueColor]){
//Already Bookmarked
[_pdfbookmark removeObjectAtIndex:currentBookmarkIndex];
self.bookmarkIndicator.tintColor = [UIColor whiteColor];
}else{
//Create Bookmark
[_pdfbookmark addObject:
@{@"deviceid": @"0",
@"page" : [NSNumber numberWithInt:[self getGlobalPageCount]],
@"fontsize" : [NSNumber numberWithInt:currentTextSize]}];
self.bookmarkIndicator.tintColor = [UIColor blueColor];
}
[bookmark setObject:_pdfbookmark forKey:_bookID];
[bookmark writeToFile:[[NSBundle mainBundle] pathForResource:@"pdfBookmarksdata" ofType:@"plist"] atomically:YES];
}