0

嗨,我在 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];
 }
4

1 回答 1

1

不允许将文件写入主包。如果您检查writeToFile:方法的返回,您将看到它返回NO

于 2013-03-28T06:41:52.633 回答