ios - NSPredicate & Parse Have it return results matching current user, but also username strings, from an array -


basically, working on chat app. in order retrieve "room" objects parse, using query this:

func loaddata(){      rooms = [pfobject]()     users = [pfuser]()      self.tableview.reloaddata()      let pred = nspredicate(format: "user1 = %@ or user2 = %@", pfuser.currentuser()!, pfuser.currentuser()!)     let roomquery = pfquery(classname: "room", predicate: pred)      roomquery.orderbydescending("lastupdate")     roomquery.includekey("user1")     roomquery.includekey("user2")      roomquery.findobjectsinbackgroundwithblock { (results, error) -> void in         if error == nil {              self.rooms = results as! [pfobject]              room in self.rooms {                 let user1 = room.objectforkey("user1") as! pfuser                 let user2 = room["user2"] as! pfuser                  if user1.objectid != pfuser.currentuser()!.objectid {                     self.users.append(user1)                 }                  if user2.objectid != pfuser.currentuser()!.objectid {                     self.users.append(user2)                 }             }              self.tableview.reloaddata()         }     }  } 

now, working fine when comes find rooms current user member of. want somewhere in app, have array of usernames(string type).

so question is: how use above nspredicate, in such way results/pfobject returned assured match of usernames in array usernames of user1 or user2.

(basically, idea that, array represents contacts , if no longer 1 should no longer see room)

please pretty please? :<

you should create array of allowed users, including current user , placeholder objects other user ids (see objectwithoutdatawithclassname:objectid:). use array in query in instead of testing direct equality (=).


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -