通过添加断点调试程序并发现指针未到达嵌套 if 语句
恐怕嵌套的 if if else 语句逻辑是正确的。
- (void)bookmarkcurrentIndex {
currentIndex = [modelArray indexOfObject:contentViewController.page];
if ([contentViewController.bookmarks containsIndex:currentIndex]) // Remove bookmark
if (BookmarkState == NO) {
[contentViewController.bookmarks removeIndex:currentIndex];
}
else {
[contentViewController.bookmarks addIndex:currentIndex];
}
}
}
编辑:
- (IBAction)bookmarkAction:(id)sender {
if (_BookmarkState != _bookmarkbtn.tag)
{
[_bookmarkbtn setImage:[UIImage imageNamed:@"Bookmark-N.png"] forState:UIControlStateNormal];
_bookmarkbtn.tag = 0;
[self setBookmarkState:NO];
}
else
{
[_bookmarkbtn setImage:[UIImage imageNamed:@"Bookmark-Y.png"] forState:UIControlStateNormal];
_bookmarkbtn.tag = 1;
[self setBookmarkState:YES];
}
_bookmarkbtn.tag = _BookmarkState;
[self bookmarkcurrentIndex];
}