core data - setFetchBatchSize Fetching all the rows in messages Table -
following code snippet.
nssortdescriptor *sortsequence = [[nssortdescriptor alloc] initwithkey:@"date_added" ascending:yes]; nsarray *sortdescriptors =[nsarray arraywithobjects:sortsequence,nil]; [fetchrequest setfetchbatchsize:5]; [fetchrequest setsortdescriptors:sortdescriptors]; [nsfetchedresultscontroller deletecachewithname:@“chats”]; nsfetchedresultscontroller *thefetchedresultscontroller =[[nsfetchedresultscontroller alloc] initwithfetchrequest:fetchrequest managedobjectcontext: managedobjectcontext sectionnamekeypath:@"messagesectionkey" cachename:@"chats"];
in listing want implement load more functionality. want sort based on key date_added
. messagesectionkey
getter method in coredata class return yesterday,today etc based on date_added
… after fetching instead of loading 5, loading rows in message
table
i guess 5 objects should set fetch limit 5
[fetchrequest setfetchlimit:5];
to 20 records , pass in parameter value of numberofitems = 20, working inside function, idea , can make own function, guess should use fetchlimit
-(void) getrecordsfor:(nsinteger) numberofrecords { .... [fetchrequest setfetchlimit: numberofrecords]; [fetchrequest setsortdescriptors:sortdescriptors]; [nsfetchedresultscontroller deletecachewithname:@“chats”]; ... }
Comments
Post a Comment