2012-03-23 53 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

相關問題