UA-17470720-3

Jump to content


Photo
- - - - -

Update/replace a section's object

models sections

  • Please log in to reply
3 replies to this topic

#1 RaduGrama

RaduGrama

    Jr. Member

  • STV 5.0 Pro
  • PipPip
  • 29 posts
  • LocationTampa, FL
Reputation: 6
Good

Posted 13 March 2016 - 09:11 PM

I have an object that is being loaded in an async fashion and I cannot guarantee that it will be available by the time objectForSection is called. Is there a recommended approach for this type of situations?



#2 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 13 March 2016 - 10:13 PM

Hi Radu,

When object loading is asynchronous, you don't implement objectForSection, but rather directly set the section's 'boundObject' property as soon as the object is fetched. Please let me know if you still need help with this.

#3 RaduGrama

RaduGrama

    Jr. Member

  • STV 5.0 Pro
  • PipPip
  • 29 posts
  • LocationTampa, FL
Reputation: 6
Good

Posted 14 March 2016 - 04:28 AM

Hi Tarek,

 

Thank you for you answer; I have a few questions/remarks on that:

  • I'm assuming that's a safe approach, the documentation indicated that 'boundObject' should be used internally only, for subclassing?
  • Can you describe the difference between 'boundObject', 'boundValue', and 'boundProperty'?
  • And last, is it safe to call that multiple times? Or how would you handle a situation where you load asynchronously most of the object, then load another part of it as a separate asynchronous request (e.g. an image associated with the object)? Would you split that in two requests or would you just wait longer in a single request?

Thank you,

Radu



#4 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 15 March 2016 - 09:54 AM

Hi Radu,

 

Yes it's safe to call multiple times. Once set, the section will regenerate its cells, so you should be refreshing the associated table view to see your changes:

[myObjectSection.ownerTableViewModel.tableView reloadData];

 

As for the 'internal' label in the docs: as long as it says it's ok to use when subclassing, then it should be fine that you use it yourself :)







Also tagged with one or more of these keywords: models, sections

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users