2012-03-23 62 views
-1

我刚刚创建了编程式的plist,并且现在插入了书签编号。如何从UItableview单元中删除选定的项目Plist词典

如何从UItableview的plist字典中删除所选项目。从commitEditingStyle 我创建的plist字典的数组,并显示上的UITableView

胀痛秩序,但是当我选择删除单元格,然后应用折痕 我cresh报告: -

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> 

pleae帮我怎么做那些东西

谢谢

回答

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返回的结果。检查您想要删除的对象是否从您的数据源中删除。

0

的删除是[tableView beginUpdates][tableView endUpdates]之间做的,当你想删除行,还必须删除从数据源中相应的对象,所以你也会有同样的数字在这两个数据源和的tableView