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

の両方で同じ番号を持つことになります
関連する問題