Welcome, Guest
Username Password: Remember me

Starting further down the hierarchy
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: Starting further down the hierarchy

Starting further down the hierarchy 1 year, 8 months ago #1

Suppose I'm using STB to show the preferences for an object. So my application handles the presentation of the higher layers of the model but when it comes down to showing preferences or settings for one of those high-level objects I want to give it to STB to handle changing the preference.

What I'd like to do is tell STB to start from a particular 'spot' in my core data hierarchy and take objects from there, so for example, I'd like to tell it to show the 'settings' property for the tenth object in an array.

Is there a way to do this? I've watched the core data tutorial and it seems like STB can easily handle a whole app, but I only want it to handle a small part of it!
  • oldbeamer
  • OFFLINE
  • Junior Boarder
  • Posts: 37
  • Karma: 0

Re: Starting further down the hierarchy 1 year, 8 months ago #2

Sure, STV can start with any object you have in your hierarchy. All you need to do is create a view controller normally, then add an SCTableViewModel just like in the videos. Next, you should add an SCObjectSection to the model, and you should be all set. Here is some sample code that should go in the implementation file (viewDidLoad) of your detail view controller:

 
...
 
NSManagedObject *myManagedObject = ... // Get your managed object of interest here
 
// Create the class definition for the managed object
SCClassDefinition *managedObjDef = [SClassDefinition definitionWithEntityName:@"managedObjEntity"
withManagedObjectContext:managedObjectContext
withPropertyNames:...];
 
// Create the table view model instance
tableViewModel = [[SCTableViewModel alloc] initWithTableView:self.tableView
withViewController:self];
 
// Create the object section
SCObjectSection *objSection = [SCObjectSection sectionWithHeaderTitle:nil
withBoundObject:myManagedObject
withClassDefinition: managedObjDef];
[tableViewModel addSection:objSection];
 
...
 


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

Re: Starting further down the hierarchy 1 year, 8 months ago #3

I see! That makes sense I'm sorry I didn't spot it myself.

Thank you for taking the time to answer promptly.
  • oldbeamer
  • OFFLINE
  • Junior Boarder
  • Posts: 37
  • Karma: 0

Re: Starting further down the hierarchy 1 year, 8 months ago #4

Please do not apologize at all, it's always our pleasure to help you out
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2404
  • Karma: 72

Re: Starting further down the hierarchy 1 year, 8 months ago #5

You're very generous with your time, thanks again and thanks for the free core data upgrade.
  • oldbeamer
  • OFFLINE
  • Junior Boarder
  • Posts: 37
  • Karma: 0
  • Page:
  • 1
Time to create page: 0.95 seconds