how to get random rows(parse objects) from parse table using android parse sdk?

前端 未结 3 451
离开以前
离开以前 2021-01-25 00:56

I have 500 records on parse class or table and now i need to get 10 random records out of 500 records?

Please tell me how can I do this.

 ParseQuery

3条回答
  •  孤城傲影
    2021-01-25 01:46

    Here is an Objective C code sample.

    PFQuery *query = [PFQuery queryWithClassName:@"MyTable"];
    int count = [query countObjects];
    
    int r = arc4random_uniform(count);
    
    PFQuery *query2 = [PFQuery queryWithClassName:@"MyTable"];
    query2.skip = r;
    
    PFObject *result = [query2 getFirstObject];
    

    `

提交回复
热议问题