Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. ParseManager.sharedManager().fetchPrice(startDate: startDate, endDate: endDate, housingId: housing.objectId!) { (objects, error) in
  2. if (objects != []) {
  3. var price = 0
  4.  
  5. for object in objects! {
  6. price += object["prix"] as! Int
  7. }
  8. price /= objects!.count
  9. self.priceByNight.text = "Price: (price)"
  10. }
  11. }
  12.  
  13. func fetchPrice(startDate: Date, endDate: Date, housingId: String, completion: PFResults?) {
  14. let params = [
  15. "startDate": startDate,
  16. "endDate": endDate,
  17. "logement": housingId
  18. ] as [String : Any]
  19.  
  20. PFCloud.callFunction(inBackground: "fetchPrice", withParameters: params) { (objects, error) in
  21. if let error = error {
  22. print(error)
  23. completion?(nil, error)
  24. return
  25. }
  26.  
  27. if let objects = objects as? [PFObject] {
  28. completion?(objects, nil)
  29. }
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement