iOS Magical Record (coredata)分页查询

   //获取查询条件

    NSFetchRequest * request = [SpeakTopicModel MR_requestAllWithPredicate:pre];

    //设置排序字段

    NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"time" ascending:YES];

    //设置排序数组

    NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];

    [request setSortDescriptors:sortDescriptors];

    //设置分页查询数目

    [request setFetchLimit:21];

    //设置查询起始

    [request setFetchOffset:1*21];

    //执行查询语句 并返回数组

    NSArray * arrayss = [SpeakTopicModel MR_executeFetchRequest:request];

 

posted on 2016-05-31 10:28  D_ye了淡淡  阅读(236)  评论(0)    收藏  举报