我刚刚以编程方式创建了plist并立即插入了书签号。
如何从UItableview中删除plist字典中的选定项目。来自commitEditingStyle 我创建了一个plist字典数组并在Uitableview上显示扩展顺序
但是当我选择删除单元格时,应用程序会出现问题 我的新报告: -
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (7) must be equal to the number of rows contained in that section before the update (7), plus or minus the number of rows inserted or deleted from that section (0 inserted, 1 deleted).'
我的plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList- 1.0.dtd">
<plist version="1.0">
<dict>
<key>0</key>
<string>5</string>
<key>1</key>
<string>1</string>
<key>2</key>
<string>2</string>
<key>3</key>
<string>6</string>
<key>4</key>
<string>3</string>
<key>5</key>
<string>3</string>
<key>6</key>
<string>1</string>
</dict>
</plist>
请帮助我如何做那些事情
谢谢
答案 0 :(得分:0)
删除是在[tableView beginUpdates]
和[tableView endUpdates]
之间完成的,当您要删除行时,还必须从dataSource中删除相应的对象,因此两者中的数字都相同。数据源和tableView
答案 1 :(得分:0)
从表视图中删除行后,第0部分中的行数为7。
invalid number of rows in section 0 The number of rows contained in an existing section after the update (7).
但它应该是6,因为你删除了一个项目。
must be equal to the number of rows contained in that section before the update (7), plus or minus the number of rows inserted or deleted from that section (0 inserted, 1 deleted).
您应该检查-(NSInteger)numberOfRowsForSection:(NSInteger)section
返回的内容。检查是否从数据源中删除了要删除的对象。