Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ParseManager.sharedManager().fetchPrice(startDate: startDate, endDate: endDate, housingId: housing.objectId!) { (objects, error) in
- if (objects != []) {
- var price = 0
- for object in objects! {
- price += object["prix"] as! Int
- }
- price /= objects!.count
- self.priceByNight.text = "Price: (price)"
- }
- }
- func fetchPrice(startDate: Date, endDate: Date, housingId: String, completion: PFResults?) {
- let params = [
- "startDate": startDate,
- "endDate": endDate,
- "logement": housingId
- ] as [String : Any]
- PFCloud.callFunction(inBackground: "fetchPrice", withParameters: params) { (objects, error) in
- if let error = error {
- print(error)
- completion?(nil, error)
- return
- }
- if let objects = objects as? [PFObject] {
- completion?(objects, nil)
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement