ios - Swift: long query in Parse (OR/AND condition) -


i need compound query parse sdk.

my code:

func retrieveobjects() {   let conditions: [string] = .....   let query: pfquery = self.generatecompoundqueryfromconditions(conditions)   query.findobjectsinbackgroundwithblock { (objs:[anyobject]?,error: nserror?) -> void in       nslog("\(objs)")   } }  private func generatecompoundqueryfromconditions(conditions: [string]) -> pfquery {     var queries: [pfquery] = []     condition: string in conditions {         var query = pfquery(classname:"myclassname")         query.wherekey("objectid", equalto: condition)         queries.append(query)     }     return pfquery.orquerywithsubqueries(queries) } 

conditions.count -> 24
code works great, error:

 [error]: many $or clauses (code: 154, version: 1.7.4) 

is there way query many or conditions?

update

i try using nspredicate:

private func generatequerywithpredicatefromconditions(conditions: [string]) -> pfquery {     var predicates: [nspredicate] = []     condition in conditions {         predicates.append(nspredicate(format: "objectid = %@", condition))     }     let predicate = nscompoundpredicate.orpredicatewithsubpredicates(predicates)     return pfquery(classname: "myclassname", predicate: predicate) } 

now error is:

'this query complex. had or >4 subpredicates after normalization.' 

so, n-or condition, i'm going n / 4 + n % 4 pfquery , merge results. solution?

i solved own in way, hope can someone:

let query = pfquery(classname: "myclassname") query.wherekey("objectid", containedin: conditions) query.findobjectsinbackgroundwithblock { (objs:[anyobject]?,error: nserror?) -> void in     nslog("\(objs)") } 

Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -