I was setting the bound object (actionCell.boundObject = order) as below:
objectsModel.sectionActions.detailModelConfigured = ^(SCTableViewSection *section, SCTableViewModel *detailModel, NSIndexPath *indexPath)
{
ServiceOrder *order = (ServiceOrder *)[detailModel sectionAtIndex:0].boundObject;
NSLog(@"Order id: %@ = %@", order.serviceOrderId, NextServiceOrderNumber);
if ([order.serviceOrderId isEqualToString:NextServiceOrderNumber]) return;
SCTableViewSection *actionSection = [SCTableViewSection section];
SCCustomCell *actionCell = [SCCustomCell cellWithText:nil
objectBindingsString:nil
nibName:@"ActionCell"];
actionCell.boundObject = order;
actionCell.tag = 10;
actionCell.cellActions.customButtonTapped = ^(SCTableViewCell *cell, NSIndexPath *indexPath, UIButton *button)
{
NSLog(@"Custom button with tag:%i has been tapped for cell at indexPath:%@.", button.tag, indexPath);
switch (button.tag) {
case 1:
[self didSelectDelete];
break;
case 2:
[self didSelectClone];
break;
case 3:
[self didSelectHistory];
break;
case 4:
[self didSelectHold];
break;
case 5:
[self didSelectServiceDetails];
break;
case 6:
[self showConfirmAlert:4 title:@"Post Service Order to Visual?"];
break;
case 7:
[self didSelectInvoice];
break;
default:
break;
}
};
actionCell.cellActions.willDisplay = ^(SCTableViewCell *cell, NSIndexPath *indexPath)
{
if([cell isKindOfClass:[SCCustomCell class]])
{
// Delete the pdf invoice just in case it exists.
if (weak_self.serviceOrder != nil) {
[weak_self deleteFile:[NSString stringWithFormat:@"%@_Invoice.pdf", weak_self.serviceOrder.serviceOrderId]];
}
weak_self.actionCellIndexPath = indexPath;
[weak_self configureActionButtons];
}
};
[actionSection addCell:actionCell];
// This adds at the end.
[detailModel addSection:actionSection];
// This adds at the begining.
//[detailModel insertSection:actionSection atIndex:0];
};
Also since I have the cell at the begining (not at the end as above) I had to change the sectionAtIndex to get the bound object at section 1:
ServiceOrder *order = (ServiceOrder *)[detailModel sectionAtIndex:1].boundObject;
Wg
Edited by wizgod, 20 October 2013 - 07:59 PM.