In the commitEditingStyle tableView method, the “.row” property is not working on the NSIndexPath. Any ideas?
Here is the call
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete)
{
NSLog(@" Delete button pushed. IndexPath:%@",indexPath);
}}
When the delete button is pushed in third row of the table the log message is:
‘Delete button pushed. IndexPath: 2 indexes [0, 2]’
If I change the log message to:
NSLog(@" Delete button pushed. IndexPath.row:%@",indexPath.row);
I get a compile error. What gives? I thought the NSIndexPath had a ‘row’ property. Obviously when I check the indexPath, it is there.
Kurt
The issue is with your format specifier.
rowproperty is of integer type so you need to use%dinstead of%@.The
.rowproperty is part of the extension category defined inUIKit.The doc is in http://developer.apple.com/library/ios/#documentation/UIKit/Reference/NSIndexPath_UIKitAdditions/Reference/Reference.html.