Welcome, Guest
Username Password: Remember me

Creating custom SCArrayOfObjectsSection cell selection action
(1 viewing) (1) Guest
  • Page:
  • 1
  • 2

TOPIC: Creating custom SCArrayOfObjectsSection cell selection action

Creating custom SCArrayOfObjectsSection cell selection action 1 year, 7 months ago #1

I'm using the code:

 
 
tableViewModel = [[SCTableViewModel alloc] initWithTableView:self.tableView withViewController:self];
 
SCClassDefinition *accountDef = [SCClassDefinition definitionWithEntityName:@"Tag"
withManagedObjectContext:self.managedObjectContext
withPropertyNames:[NSArray arrayWithObject:@"name"]];
 
SCArrayOfObjectsSection *objectSection = [SCArrayOfObjectsSection sectionWithHeaderTitle:nil withEntityClassDefinition:accountDef];
[tableViewModel addSection:objectSection];
 
 


Aside from subclassing SCTableViewModel, I'd like to override tableView:didSelectRowAtIndexPath:. Well to be more accurate, I'd like to have SCTableViewModel ignore it so that I can use the delegate method tableViewModel:didSelectRowAtIndexPath:.

Instead when a cell is clicked a detail view controller is displayed. I'd like to display my own controller using the boundobject of the selected cell.

Can I do that without subclassing SCTableViewModel?

Gary
  • panamind
  • OFFLINE
  • Senior Boarder
  • Posts: 77
  • Karma: 4

Re: Creating custom SCArrayOfObjectsSection cell selection action 1 year, 7 months ago #2

No need to subclass SCTableViewModel at all Gary.

To implement what you want, please follow these steps:

1- Set the SCArrayOfObjectsSection allowEditDetailView property to FALSE

 
...
objectSection.allowEditDetailView = FALSE;
...
 


2- Implement the SCTableViewModelDelegate method called tableViewModel:didSelectRowAtIndexPath:

 
- (void)tableViewModel:(SCTableViewModel *)tableViewModel
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
switch(indexPath.row)
{
// do what you want here
}
}
 


Hope this helps.
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2404
  • Karma: 72

Re: Creating custom SCArrayOfObjectsSection cell selection action 1 year, 7 months ago #3

I just knew it was a one line solution.

Thanks
  • panamind
  • OFFLINE
  • Senior Boarder
  • Posts: 77
  • Karma: 4

Re: Creating custom SCArrayOfObjectsSection cell selection action 1 year, 7 months ago #4

I am implementing the method


- (void)tableViewModel:(SCTableViewModel *)tableViewModel
didSelectRowAtIndexPath:(NSIndexPath *)indexPath

myself and have been wondering how to properly get the selected index number. I see that indexpath.row works, but I could not find this documented in the reference docs. Is that going to be a problem, given all the noise about private APIs and appstore acceptance. Or did I get this wrong? (I am new to the iPhone world).
  • wolpers
  • OFFLINE
  • Fresh Boarder
  • Posts: 4
  • Karma: 0

Re: Creating custom SCArrayOfObjectsSection cell selection action 1 year, 7 months ago #5

Hi Thorsten:

This is not private API at all, we use it all the time You just need to check NSIndexPath(UITableView) in Apple's documentation (you probably looked up just NSIndexPath which confusingly enough is used to represent a tree node too! ).
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2404
  • Karma: 72
Last Edit: 1 year, 7 months ago by tarekskr.

Re: Creating custom SCArrayOfObjectsSection cell selection action 1 year, 7 months ago #6

Wolpers, this is not a problem.

NSIndexPath is a documented UIKit/AppKit class the SCT passes indexPath from the documented
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath


UITableView delegate method.
  • panamind
  • OFFLINE
  • Senior Boarder
  • Posts: 77
  • Karma: 4
  • Page:
  • 1
  • 2
Time to create page: 0.99 seconds