UA-17470720-3

Jump to content


Photo
- - - - -

load more cell in SCArrayOfObjectModel

models cells core-data web-services

  • Please log in to reply
7 replies to this topic

#1 Balachandhar

Balachandhar

    Experienced Member

  • STV 3.0 Pro
  • PipPipPipPip
  • 87 posts
Reputation: 21
Excellent

Posted 18 October 2013 - 12:02 PM

hi,

 

i am using coredata, i used SCArrayOfObjectModel throughout my app. now i want to implement load more cell. 

 

note:backend is stackmob

 

is it posible to use batch, load more cell in SCArrayOfObjectModel? 

is it the load more cell will be used only when i use SCArrayOfObjectSection?

 

thanks

bala


  • cratrenue and hwf9vjkj8s2 like this

#2 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 19 October 2013 - 08:28 AM

Hi bala,

You can still use SCFetchItemsCell in SCArrayOfObjectsModel exactly the same way as you do with SCArrayOfObjectsSection. All you need to do is configure your SCEntityDefinition to get the data in batches from Core Data.

Hope this helps.



#3 wizgod

wizgod

    I'm what you guys call a User

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 575 posts
  • LocationThe Grid
Reputation: 149
Popular

Posted 19 October 2013 - 03:21 PM

Tarek! Where have you been hiding??

 

When I add:

objectsModel.dataFetchOptions.batchSize = 20;

 

The tableview shows the 20 rows but does not show the "Load More..." cell and if I add it as such in the objectsModel.sectionActions.didFetchItemsFromStore, it throws an error at runtime.

objectsModel.sectionActions.didFetchItemsFromStore = ^(SCArrayOfItemsSection *itemsSection, NSMutableArray *items)
{
    // I tried adding this here too with no luck.
    //itemsSection.dataFetchOptions.batchSize = 20;
    SCFetchItemsCell *fetchItemsCell = [SCFetchItemsCell cellWithText:@"Load more..." textAlignment:NSTextAlignmentCenter];
    [itemsSection addCell:fetchItemsCell];
}

 

Any thoughts?

 

Wg


P.S. I love Swift... talk Swift.. Never too old school to learn yet another programming language. LOL! ;-)


#4 ozie

ozie

    ¯\_(ツ)_/¯

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 526 posts
  • LocationAustralia
Reputation: 169
Popular

Posted 20 October 2013 - 01:53 AM

WG.. Isn't it just (new line after the batch size)
objectsModel.fetchItemsCell = [SCFetchitemsCell ".................

Don't need to add it in the block

P.S. I hate Swift.. don't talk Swift.. Too old school to learn yet another programming language.


#5 wizgod

wizgod

    I'm what you guys call a User

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 575 posts
  • LocationThe Grid
Reputation: 149
Popular

Posted 20 October 2013 - 08:16 PM

WG.. Isn't it just (new line after the batch size)
objectsModel.fetchItemsCell = [SCFetchitemsCell ".................

Don't need to add it in the block

 

Hey Oz, I tried but the .fetchItemsCell isn't available in the objectsModel like that.

 

Wg


P.S. I love Swift... talk Swift.. Never too old school to learn yet another programming language. LOL! ;-)


#6 Balachandhar

Balachandhar

    Experienced Member

  • STV 3.0 Pro
  • PipPipPipPip
  • 87 posts
Reputation: 21
Excellent

Posted 21 October 2013 - 10:00 AM

Can anyone add the code snippet here?



#7 ozie

ozie

    ¯\_(ツ)_/¯

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 526 posts
  • LocationAustralia
Reputation: 169
Popular

Posted 21 October 2013 - 02:20 PM

    SCArrayOfObjectsSection *objectsSection = [SCArrayOfObjectsSection
                                               sectionWithHeaderTitle:nil entityDefinition:myDef];
    objectsSection.fetchItemsCell = ......

to just create it normally

 

 

and for the SCArrayofObjectsModel

 

    SCArrayOfObjectsModel *m = [SCArrayOfObjectsModel modelWithTableView:blah entityDefinition:blah];
    m.modelActions.didAddSection = ^(SCTableViewModel *tableModel, SCTableViewSection *section, NSUInteger sectionIndex)
    {
        SCArrayOfObjectsSection *objectsSection = (SCArrayOfObjectsSection *)section;
        objectsSection.fetchItemsCell = [SCFetchItemsCell ....
        
    };

 

 

Oz


Edited by ozie, 21 October 2013 - 02:29 PM.

P.S. I hate Swift.. don't talk Swift.. Too old school to learn yet another programming language.


#8 Balachandhar

Balachandhar

    Experienced Member

  • STV 3.0 Pro
  • PipPipPipPip
  • 87 posts
Reputation: 21
Excellent

Posted 23 October 2013 - 01:47 AM

Thanks Ozie.

 

I ended with the below snippet, but whenever i click the laodmore cell, i am getting duplicates of the existing batch items instead of loading next batch.

 

Also, pull to refresh action is removing the "loadmore" cell. what should i do to show the loadmore always?

 

    tasksModel = [SCArrayOfObjectsModel modelWithTableView:self.tableView entityDefinition:taskdef filterPredicate:nil];

    

    fetchedOptions = [SCCoreDataFetchOptions optionsWithSortKey:NO sortAscending:YES filterPredicate:compoundPredicate];

    fetchedOptions.batchSize = 4;

    [tasksModel setDataFetchOptions:fetchedOptions];


Edited by Balachandhar, 23 October 2013 - 01:53 AM.






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

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users