Advertisement
Guest User

Untitled

a guest
May 29th, 2015
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. func addConnection(targetUser:SparksUser) {
  2. connectionButton.setTitle("Pending", forState: UIControlState.Normal)
  3. connectionButton.enabled = false
  4. let currentUser = SparksUser.currentUser()!
  5. //
  6. // var areConnections = Connection.query()
  7. // areConnections?.whereKey("currentUser", equalTo: SparksUser.currentUser()!)
  8. // areConnections?.whereKey("targetUser", equalTo: newConnection)
  9. // areConnections?.countObjectsInBackgroundWithBlock({ (count, error) -> Void in
  10. // if error != nil {
  11. // self.connectionButton.setTitle("Request", forState: UIControlState.Normal)
  12. // println(error)
  13. // return
  14. // }
  15. //
  16. // if count > 0 {
  17. // // They are already connected
  18. // println("They are already connections")
  19. // } else {
  20. // add connection
  21. var connection = Connection()
  22. var notification = Notification()
  23.  
  24. connection.currentUser = currentUser
  25. connection.targetUser = targetUser
  26. connection.status = .Requested
  27.  
  28. notification.fromUser = currentUser
  29. notification.targetUser = targetUser
  30. notification.title = "Connection Request From:"
  31. notification.text = "\(currentUser.username!)"
  32. notification.read = false
  33.  
  34. // notification.saveInBackgroundWithBlock({ (success, error) -> Void in
  35. // if error != nil {
  36. // println("This was the error: \(error)")
  37. // }
  38. // })
  39. notification.saveInBackgroundWithBlock(nil)
  40. connection.saveInBackgroundWithBlock(nil)
  41.  
  42. println("connecting \(connection.currentUser) and \(connection.targetUser)")
  43. // }
  44. self.connectionStatus = ConnectionRequestStatus.Requested
  45. self.updateConnectionStatus()
  46. // })
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement