Advertisement
Guest User

Untitled

a guest
Jan 29th, 2016
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 1.03 KB | None | 0 0
  1.  
  2.         let myLocation = PFGeoPoint(latitude: 34.415075, longitude: -119.862538)
  3.         var results = ATMsAroundMe(myLocation)
  4.  
  5.  
  6.  
  7. func ATMsAroundMe(myLocation : PFGeoPoint) -> [ATM]{
  8.         var results = [ATM]()
  9.         var query = PFQuery(className: "ATMs")
  10.         query.whereKey("location", nearGeoPoint: myLocation, withinMiles: 5)
  11.         query.limit = 10
  12.         query.findObjectsInBackgroundWithBlock { (atms: [PFObject]?, error: NSError?) -> Void in
  13.             if (error == nil) {
  14.                 for atm in atms! {
  15.                     if let result : ATM? = ATM.init(id: atm.objectId!){
  16.                         //Add the result to the results array
  17.                         print("Successful")
  18.                         print(result?.bank)
  19.                         results.append(result!)
  20.                     }
  21.                     else{
  22.                        
  23.                     }
  24.                 }
  25.                
  26.             } else {
  27.                 // Log details of the failure
  28.             }
  29.         }
  30.     return results
  31.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement