UA-17470720-3

Jump to content


Photo
- - - - -

Intercept 'done' button tap?


  • Please log in to reply
11 replies to this topic

#1 Seth Vanderdrift

Seth Vanderdrift

    Advanced Member

  • STV 5.0 Pro
  • PipPipPipPipPip
  • 108 posts
Reputation: 20
Excellent

Posted 08 May 2011 - 11:30 PM

It's probably in there somewhere, but I can't find where to intercept the 'done' button being tapped in an when an object is 'done' editing?

I'm not getting tableViewModelDidEndEditing to fire. (or the Will variation)

I'm doing a classroom attendence app, and tableViewModel:detailViewWillAppearForRowAtIndexPath:withDetailTableViewModel: adds a SCSelectionSection to the bottom of the detailTableViewModel. I add all the students from the schoolClass definition to the selection section. This part works great.

But I can't figure out how to interecept the 'done' (or cancel button) for that matter when the editing is complete so I can save the changes by extracting the SelectedIndexesValue(s) from the section and update the individual student records.

(I'm doing it this way, because I don't want another drilldown level for the student SCSelectionSection, and a datamodel design decision)

I guess I need to know if the done or cancel is tapped.

Thanks
Seth

#2 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 10 May 2011 - 03:26 PM

Hi Seth,

You can determine that by storing the detail view in a variable in detailViewWillAppear, then implementing the detailViewWillDisappear and checking for which button has been tapped. Your code should look something like that:

- (void)tableViewModel:(SCTableViewModel *)tableViewModel detailViewWillAppearForRowAtIndexPath:(NSIndexPath *)indexPath withDetailTableViewModel:(SCTableViewModel *)detailTableViewModel
{
  // detailView is a member variable of type SCTableViewController
  detailView = (SCTableViewController *)detailTableViewModel.viewController;
  ...
}

- (void)tableViewModel:(SCTableViewModel *)tableViewModel detailViewWillDisappearForRowAtIndexPath:(NSIndexPath *)indexPath
{
  if(detailView.doneButtonTapped)
	...
}

Hope this helps!

#3 Seth Vanderdrift

Seth Vanderdrift

    Advanced Member

  • STV 5.0 Pro
  • PipPipPipPipPip
  • 108 posts
Reputation: 20
Excellent

Posted 10 May 2011 - 04:12 PM

Thanks,

Just to be clear, I need to declare detailView as a module variable, so I can save it across the two 'callbacks'.

I save detailView in etailViewWillAppearForRowAtIndexPath: because the detailTableViewModel is available there, and it contains the SCTableViewController I need to access in detailViewWillDisappearForRowAtIndexPath:

--

Do you have a snippet at hand which returns/retrieves the managed object associated with indexPath in detailViewWillDisappearForRowAtIndexPath:?

I won't be able to get back into xcode until this evening.

Thanks again,
Seth
  • carl grainger likes this

#4 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 11 May 2011 - 09:51 AM

Hi Seth,

Do you have a snippet at hand which returns/retrieves the managed object associated with indexPath in detailViewWillDisappearForRowAtIndexPath:?


Sure, that's actually very simple! Just use the cell's boundObject property:

...
SCTableViewCell *myCell = [tableViewModel cellAtIndexPath:indexPath];
NSManagedObject *myObject = (NSManagedObject *)myCell.boundObject;
...

Hope this helps.

#5 Seth Vanderdrift

Seth Vanderdrift

    Advanced Member

  • STV 5.0 Pro
  • PipPipPipPipPip
  • 108 posts
Reputation: 20
Excellent

Posted 11 May 2011 - 11:23 PM

Tarek,

I'm not getting tableViewModel:detailViewWillDisappearForRowAtIndexPath called.

I have the SCTableViewModelDeletage properly setup in the .h

detailViewWillAppearForRowAtIndexPath is being called.
detailModelCreatedForRowAtIndexPath is being called.

Specifically I have:

#pragma mark -
#pragma mark SCTableViewModelDelegate methods

// THIS ONE NOT CALLED
- (void)tableViewModel:(SCTableViewModel *) tableViewModel detailViewWillDisappearForRowAtIndexPath:(NSIndexPath *) indexPath
{
	
	NSLog(@"detailViewWillDisappearForRowAtIndexPath");
	
}


// THIS ONE CALLED OK
- (void)tableViewModel:(SCTableViewModel *)tableViewModel detailViewWillAppearForRowAtIndexPath:(NSIndexPath *)indexPath withDetailTableViewModel:(SCTableViewModel *)detailTableViewModel
{
	
	// detailView is a member variable of type SCTableViewController
	//detailView = (SCTableViewController *)detailTableViewModel.viewController;
	NSLog(@"detailViewWillAppearForRowAtIndexPath:");
	
}

// THIS ONE CALLED OK
- (void)tableViewModel:(SCTableViewModel *)tableViewModel detailModelCreatedForRowAtIndexPath:(NSIndexPath *)indexPath  detailTableViewModel:(SCTableViewModel *)detailTableViewModel
{
	
	NSLog(@"detailModelCreatedForRowAtIndexPath");
	detailTableViewModel.delegate = self;
	
	// Set the tag property of the detail model to correspond to its level in the hierarchy
	detailTableViewModel.tag = tableViewModel.tag + 1;
}

As a test, I took the 2.0.5 Coredata sample, and added to PeopleViewController.h, so it would call the delegate methods.

I then added the above snipped to PeopleViewController.m

As in my program, it's calling detailModelCreated... and detailViewWillAppear...
Here's the console display:
[Session started at 2011-05-11 21:47:00 -0400.]
2011-05-11 21:47:06.581 Core Data App[25829:207] detailModelCreatedForRowAtIndexPath
2011-05-11 21:47:06.584 Core Data App[25829:207] detailViewWillAppearForRowAtIndexPath:

I'm expecting that it should call the detailViewWillDisappearForRowAtIndexPath:, but it's not.

Any ideas?

Thanks
SEth

#6 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 12 May 2011 - 02:30 AM

Hi Seth,

We were able to replicate your issue, thank you very much for reporting this! This glitch should be fixed in our next minor release. Thanks again!

#7 Seth Vanderdrift

Seth Vanderdrift

    Advanced Member

  • STV 5.0 Pro
  • PipPipPipPipPip
  • 108 posts
Reputation: 20
Excellent

Posted 13 May 2011 - 10:58 PM

Great.

Any ETA on the fix for this? I've got plenty other code to write, but I'm dead in the water for saving my changes in one view without this delegate method.

Thanks
Seth

#8 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 17 May 2011 - 02:09 PM

Hi Seth,

We're now working really hard to release STV 2.1 in a couple of weeks time. If you can't wait for the fix, please tell me and I'll wrap up a special beta release for you in a day or two.

Thanks!

#9 Seth Vanderdrift

Seth Vanderdrift

    Advanced Member

  • STV 5.0 Pro
  • PipPipPipPipPip
  • 108 posts
Reputation: 20
Excellent

Posted 17 May 2011 - 03:57 PM

Tarek,

A beta would help tremendously. I can't save any edits without these delegate methods being called. I'm trying to get a functional prototype to show my boss and get this project from night work, to officially sanctioned (read PAID) day work.

Thank you very much.
Seth

#10 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 17 May 2011 - 09:47 PM

No problem at all, I'll send you a beta ASAP :)

#11 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 20 May 2011 - 07:06 PM

Hi Seth,

We're still having some issues with STV 2.1 beta, so to not to keep you waiting, we've created a new incremental update (2.0.5.5) that fixes the detailViewWillDisappearForRowAtIndexPath issue. I'll send you the update right away, please tell me if it's working well for you. Thanks!

#12 Seth Vanderdrift

Seth Vanderdrift

    Advanced Member

  • STV 5.0 Pro
  • PipPipPipPipPip
  • 108 posts
Reputation: 20
Excellent

Posted 20 May 2011 - 07:08 PM

EXCELLENT,

Thank you very much.

Seth




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users