您好我在xcode中创建了一个plist(newfile->resourses->property list
就像这样)并且我尝试向该plist添加一个NSDictionary
但是它没有添加,请帮我这里是我的代码
-(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];
}
答案 0 :(得分:1)
您不能将文件写入主包。如果您检查writeToFile:
方法的返回,您会看到它返回NO
。