UA-17470720-3

Jump to content


Photo
- - - - -

SCTableViewCell Disable commitChangesLive

general core-data cells sections models

  • Please log in to reply
4 replies to this topic

#1 Sam Gerardi

Sam Gerardi

    Jr. Member

  • STV 3.0 Std
  • PipPip
  • 27 posts
  • LocationSan Diego, CA
Reputation: 5
Good

Posted 27 October 2012 - 03:15 PM

When I am in editing mode in my table view, and I make changes to a textfield cell, and I press the cancel button, the original values are not reloaded into the cells. I am assuming I need to disable CommitChangesLive for every cell. If I disable this option for every cell, how Do I commit the changes when the done button is pressed?

The tableViewModel is generated from an SCEntityDefinition using generateSectionsForObject:withDefinition:newObject;

#2 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 29 October 2012 - 08:45 PM

Hi Sam,

Thanks a lot for posting this. You actually don't need to do anything at all, as this should be the default functionality out of the box. Would you mind posting a relevant portion of the code that generates this table view? Thanks again!

#3 Sam Gerardi

Sam Gerardi

    Jr. Member

  • STV 3.0 Std
  • PipPip
  • 27 posts
  • LocationSan Diego, CA
Reputation: 5
Good

Posted 29 October 2012 - 08:54 PM

I have since deleted the code and tried something different. I am using coredata. However it appears that the cells that are created by the generateSectionsForObject:withDefinition:newObject method, when in editing mode, will commit changes as they are being made. Pressing the cancel button essentially does nothing in this instance except for exit editing mode. Is this the appropriate function? do I need to disable the commitChangesLive property for the cancel button to work properly and reload the default values? I did see that it will commit the changes after the done button has been pressed when I disable the commitChangesLive property.

#4 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 29 October 2012 - 09:01 PM

No, this is not what's supposed to happen. The correct scenario is that as soon as the cancel button is tappen, all the modifications should be ignored and the original data is loaded. Do you observe the same problems with our own Core Data samples?

#5 Sam Gerardi

Sam Gerardi

    Jr. Member

  • STV 3.0 Std
  • PipPip
  • 27 posts
  • LocationSan Diego, CA
Reputation: 5
Good

Posted 29 October 2012 - 09:10 PM

I looked at the core data samples and they do work properly, however the core data sample project is generating the tableModel by creating and adding an SCArrayOfObjectsSection and by creating a SCArrayOfObjectsModel and replacing the tableModel, not from the generateSectionsForObject:withDefinition. Here is the code I just tested to confirm. It is an instance of SCTableViewController.

- (void)viewDidLoad
{
[super viewDidLoad];
	
self.navigationBarType = SCNavigationBarTypeEditRight;

SCEntityDefinition *projectEntity = [SCEntityDefinition definitionWithEntityName:@"Project" managedObjectContext:managedObjectContext propertyNames:@[@"name", @"job"]];

projectEntity.requireEditingModeToEditPropertyValues = YES;


[self.tableViewModel generateSectionsForObject:project withDefinition:projectEntity];
}

The project is a property of the class Project generated by core data. No changes have been made to the class. I have only overriden the viewDidLoad method. Both the name and job attributes are strings. When I press edit the tableView changes to editing mode. Change the value of a text field. Press cancel and the tableView exits editing mode and the values do not change. Is there something wrong with this code?

Edited by Sam Gerardi, 29 October 2012 - 09:13 PM.






Also tagged with one or more of these keywords: general, core-data, cells, sections, models

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users