UA-17470720-3

Jump to content


Photo
- - - - -

Placeholder Text when using SCArrayOfObjectsModel


  • 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 05 April 2016 - 03:51 PM

Is there a way to set a Placeholder Text when using SCArrayOfObjectsModel, in effect having a section appear displaying the Placeholder Text when there are no entities to display?



#2 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 05 April 2016 - 07:17 PM

Hi Radu,

 

Does your model only display objects, or do you add your own objects as well? If it only displays objects, then you could use the following:

 

self.tableViewModel.modelActions.didFetchItemsFromStore = ^(SCArrayOfItemsModel *itemsModel, NSMutableArray *items)
    {
        if(!items.count)
        {
            SCTableViewCell *placeholderCell = [SCTableViewCell cellWithText:@"(no objects!)" textAlignment:NSTextAlignmentCenter];
            [items addObject:placeholderCell];
        }
    };

 

 

If you also need to add objects at runtime, then please let us know and we'll add a new 'placeholder' property to SCArrayOfObjectsModel (also please let me know if it's urgent).



#3 RaduGrama

RaduGrama

    Jr. Member

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

Posted 05 April 2016 - 07:26 PM

Hi Tarek,

 

Thank you for the answer!

 

I assume this will work only if there are no objects added at runtime. In my scenario I do need to add objects at runtime, and I was assuming the SCArrayOfObjectsModel instance would pick up the placeholder property set in IB in the SCArrayOfObjectsSection. This is not urgent but it would be nice to have, it would allow us to keep consistency with screens that don't need to use SCArrayOfObjectsModel.

 

Thank you,

Radu 



#4 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 05 April 2016 - 07:27 PM

Yes this is exactly how we will design it, it will automatically pick up whatever placeholder you've set in IB.

 

Thank you Radu!


  • RaduGrama likes this




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users