UA-17470720-3

Jump to content


Photo
- - - - -

Changing bound value of SCTableViewSection


  • Please log in to reply
8 replies to this topic

#1 Panamind

Panamind

    Experienced Member

  • STV 3.0 Pro
  • PipPipPipPip
  • 77 posts
Reputation: 1
Good

Posted 05 November 2010 - 01:09 PM

Instead of editing the bound object I'd like to change the object (object is same class). SCTableViewSection has a bound object property but I get errors when I try:

 
[tableModel sectionAtIndex:0].boundObject = newObject];


or

[[tableModel sectionAtIndex:0] setBoundObject:newObject];

How do you change the bound object so that I can call [tableModel reloadBoundValues];

#2 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 05 November 2010 - 01:17 PM

Hi Gary,

The "boundObject" property is an internal property and should never be directly accessed (as per the documentation).

Would you please tell me more about the type of model you're using? Is it a normal SCTableViewModel or an SCArrayOfObjectsModel?

#3 Panamind

Panamind

    Experienced Member

  • STV 3.0 Pro
  • PipPipPipPip
  • 77 posts
Reputation: 1
Good

Posted 05 November 2010 - 01:29 PM

	// Initialize tableModel
	tableModel = [[SCTableViewModel alloc] initWithTableView:self.tableView withViewController:self];
	
	// Create Case class definition
	SCClassDefinition *firstClassDef = [SCClassDefinition definitionWithClass: ... withPropertyNames: ... ];
	
...	
	
	   SCObjectSection *firstSection = [SCObjectSection sectionWithHeaderTitle:nil withBoundObject:self.sourceObj withClassDefinition:firstClassDef];
	[tableModel addSection:firstSection];

	SCClassDefinition *secondClassDef = [SCClassDefinition definitionWithClass: ... withPropertyNames: ... ];

...

	SCObjectSection *secondSection = [SCObjectSection sectionWithHeaderTitle:nil withBoundObject:self.sourceObj withClassDefinition:secondClassDef];
	[tableModel addSection:secondSection];
	
	SCClassDefinition *thirdClassDef = [SCClassDefinition definitionWithClass: ... withPropertyNames: ... ];

...

	SCObjectSection *thirdSection = [SCObjectSection sectionWithHeaderTitle:nil withBoundObject:self.sourceObj withClassDefinition:thirdClassDef];
	[tableModel addSection:thirdSection];


Instead of editing the bound object, I replace it e.g. [self setSourceObj:newObj]; external to viewcontroller

Gary

#4 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 05 November 2010 - 01:34 PM

In this case you should just replace the section itself, then call [tableModel.modeledTableView reloadData].

#5 Panamind

Panamind

    Experienced Member

  • STV 3.0 Pro
  • PipPipPipPip
  • 77 posts
Reputation: 1
Good

Posted 05 November 2010 - 01:39 PM

OK, that'll work, I'll just refactor out the code that creates the sections.

#6 Brendan Duddridge

Brendan Duddridge

    Advanced Member

  • STV 5.0 Pro
  • PipPipPipPipPip
  • 170 posts
Reputation: 7
Good

Posted 27 February 2011 - 06:05 PM

I think it would be great to be able to set the boundObject on a cell. In my situation I have a table cell with no object bound initially because it just doesn't exist in the database until you select a value from a UIPopoverController. Then the value gets created in the database. It'd be a shame to have to reload the entire table just for changing one value.

Thanks,

Brendan

#7 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 01 March 2011 - 04:46 AM

Hi Brendan,

Thanks for the suggestion!

After initially studying the current architecture, I think we can safely redefine boundObject as a retain property (instead of the current readOnly). We might then need to implement some code in the boundObject setter, but that should not be a big deal.

We'll have this part of the final 2.0 release. Thanks again!

#8 Brendan Duddridge

Brendan Duddridge

    Advanced Member

  • STV 5.0 Pro
  • PipPipPipPipPip
  • 170 posts
Reputation: 7
Good

Posted 01 March 2011 - 08:39 AM

That would be awesome Tarek!

Please let me know if you have a beta of that feature ready any time. I'd love to test it for you.

Thanks!

Brendan

#9 halldorg

halldorg

    Jr. Member

  • STV 5.0 Std
  • PipPip
  • 26 posts
Reputation: 5
Good

Posted 16 February 2016 - 05:18 PM

Have there been changes to this so bound objects can be changed?


  • RaduGrama likes this




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users