Advertisement
Guest User

Untitled

a guest
Aug 14th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.57 KB | None | 0 0
  1. let roomsData = QRoom.all() // get from database
  2. var withIds = [String]()
  3. for item in roomsData {
  4. withIds.append(item.id) // add to array temporary
  5. }
  6.  
  7. var newIds = ["212"] // if there is new data, example room id
  8.  
  9. var set1 = Set(newIds)
  10. var set2 = Set(withIds)
  11. let filter = Array(set1.subtracting(set2)) // check whether is exist in database or not
  12. if(filter.count > 0){
  13.     // if there is no in database then call room info API server
  14.     Qiscus.roomsInfo(withIds: filter, onSuccess: { (qRooms) in
  15.     // success gaining rooms
  16.     }) { (error) in
  17.     // error gaining rooms
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement