Guest User

Untitled

a guest
Oct 4th, 2018
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. protocol ConnectionServerProtocol {
  2. func connectWithUsernameAndPassword(username: String, password: String)
  3. }
  4.  
  5. public class ConnectionServer: NSObject {
  6. var username: String?
  7. var password: String?
  8. let connectionServerProtocol: ConnectionServerProtocol
  9.  
  10. public init(connectionServerProtocol: ConnectionServerProtocol) {
  11. self.connectionServerProtocol = connectionServerProtocol
  12. }
  13. }
  14.  
  15. public func connectWithUsernameAndPassword(username: String, password: String) {
  16.  
  17. self.username = username
  18. self.password = MD5(password)
  19. self.connectionServerProtocol.dataTask()
  20. }
  21.  
  22. self.connectionServerProtocol.connectWithUsernameAndPassword(username:"someUserName", password: "SomePassword")
  23.  
  24. let cs = ConnectionServer()
  25.  
  26. let cs = ConnectionServer(connectionServerProtocol:ConnectionServerProtocol)
  27.  
  28. let cs = ConnectionServer(connectionServerProtocol: ConnectionServerProtocol.self as! ConnectionServerProtocol)
  29.  
  30. let cs = ConnectionServer.self
  31. cs.connectWithUsernameAndPassword(username: SomeUserName", password:"SomePassword")
  32.  
  33. public class ConnectionServer: NSObject, ConnectionServerProtocol {
  34. }
  35.  
  36. cs.connectWithUsernameAndPassword(username: SomeUserName", password:"SomePassword")
Add Comment
Please, Sign In to add comment