Reputation: 1251
Hi i created one plist in xcode (newfile->resourses->property list
like this) and i try to add one NSDictionary
to that plist but its not adding ,please help me here is my code
-(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];
}
Upvotes: 0
Views: 78
Reputation: 33421
You are not allowed to write files to your main bundle. If you check the return of the writeToFile:
method, you will see that it returns NO
.
Upvotes: 1