UA-17470720-3

Jump to content


Photo
- - - - -

Migrating to SectionActions from SCTableViewModelDelegate


  • Please log in to reply
7 replies to this topic

#1 sebaro1989

sebaro1989

    Jr. Member

  • STV Lite
  • PipPip
  • 17 posts
Reputation: 4
Good

Posted 23 February 2016 - 02:06 PM

Hi, i'm currently trying to fix a problem that I have since i upgraded to STV 5, i´m currently modifying a class to fit the deprecated methods SCTableViewModelDelegate and i can't find a SectionAction to fit this method:

 

 

(BOOL)tableViewModel:(SCTableViewModel *)tableViewModel shouldDismissDetailViewForRowAtIndexPath:(NSIndexPath *)indexPath withDetailTableViewModel:(SCTableViewModel *)detailTableViewModel cancelButtonTapped:(BOOL)cancelTapped doneButtonTapped:(BOOL)doneTapped
 

 

I know that i could use: 

 

detailModelShouldDismiss
 

but how could i get the doneButtonTapped at the same time?

 

Thanks in advance,

Regards,

Sebastián


  • Milanon, VewSnignineroqn and Adjuramum like this

#2 ozie

ozie

    ¯\_(ツ)_/¯

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 526 posts
  • LocationAustralia
Reputation: 169
Popular

Posted 23 February 2016 - 03:32 PM

self.actions.doneButtonTapped

 

or using the delegate <SCTableViewControllerDelegate>

 

and then one of these

 

- (BOOL)tableViewControllerShouldDismiss:(SCTableViewController *)tableViewController
                 cancelButtonTapped:(BOOL)cancelTapped doneButtonTapped:(BOOL)doneTapped;


- (void)tableViewControllerWillDismiss:(SCTableViewController *)tableViewController
               cancelButtonTapped:(BOOL)cancelTapped doneButtonTapped:(BOOL)doneTapped;


- (void)tableViewControllerDidDismiss:(SCTableViewController *)tableViewController
                   cancelButtonTapped:(BOOL)cancelTapped doneButtonTapped:(BOOL)doneTapped;

Edited by ozie, 23 February 2016 - 03:34 PM.

P.S. I hate Swift.. don't talk Swift.. Too old school to learn yet another programming language.


#3 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 23 February 2016 - 03:33 PM

Hi Sebastián,

 

You can simply check viewController.doneButtonTapped:

 

sectionActions.detailModelDidDismiss = ^(SCTableViewSection *section, SCTableViewModel *detailModel, NSIndexPath *indexPath)
{
    if([detailModel.viewController isKindOfClass:[SCTableViewController class]])
    {
       SCTableViewController *viewController = (SCTableViewController *)detailModel.viewController;
       if(viewController.doneButtonTapped)
       {
          ...
       }
    }
};


#4 ozie

ozie

    ¯\_(ツ)_/¯

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 526 posts
  • LocationAustralia
Reputation: 169
Popular

Posted 23 February 2016 - 03:37 PM

god thats a lot of code just to work out if the done button was tapped or not.. was there any chance the done,edit and cancel buttons would get their own model action?


P.S. I hate Swift.. don't talk Swift.. Too old school to learn yet another programming language.


#5 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 23 February 2016 - 03:39 PM

It's actually only one line of code, I just added a lot of other boiler plate to not cause confusion and because I don't know if Sebastián is using the default STV controllers.

 

sectionActions.detailModelDidDismiss = ^(SCTableViewSection *section, SCTableViewModel *detailModel, NSIndexPath *indexPath)
{
    if([(SCTableViewController *)detailModel.viewController doneButtonTapped])
       {
          ...
       }
    }
};

  • ozie likes this

#6 ozie

ozie

    ¯\_(ツ)_/¯

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 526 posts
  • LocationAustralia
Reputation: 169
Popular

Posted 23 February 2016 - 04:20 PM

nice

 

but thats kinda hidden even for me to think of trying something like that

 

can we get something that stands out.. I looked through all the code in Dash and couldn't find any help on something simple as this, since there is no direct access to it

 

what about something like sectionActions.detailModelDoneButtonTapped ?? 

 

or adding the var for the action used incorporated with 

sectionActions.detailModelDidDismiss = ^(SCTableViewSection *section, SCTableViewModel *detailModel, NSIndexPath *indexPath)

like 

sectionActions.detailModelDidDismiss = ^(SCTableViewSection *section, SCTableViewModel *detailModel, NSIndexPath *indexPath, STVActionButton button)

 

makes it easier for us to also find info in the help file :)


  • Tarek and Dave Guerin like this

P.S. I hate Swift.. don't talk Swift.. Too old school to learn yet another programming language.


#7 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 23 February 2016 - 06:44 PM

Thanks ozie, I do understand where you're coming from :)

 

I like your second solution best, but we need to find a way to implement that without breaking any of our users' existing code.



#8 sebaro1989

sebaro1989

    Jr. Member

  • STV Lite
  • PipPip
  • 17 posts
Reputation: 4
Good

Posted 24 February 2016 - 10:45 AM

Ozie, Tarek, thanks for your quick reply as usual!, i managed to add the action and it worked like a charm! 

 

 

Thanks again,

Sebastian






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users