File tree 1 file changed +9
-5
lines changed
1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -71,18 +71,22 @@ public class Session {
71
71
}
72
72
}
73
73
74
- // Shared session for static methods
75
- public static let sharedSession = Session ( URLSession: NSURLSession (
74
+ // Shared session for class methods
75
+ private static let privateSharedSession = Session ( URLSession: NSURLSession (
76
76
configuration: NSURLSessionConfiguration . defaultSessionConfiguration ( ) ,
77
77
delegate: URLSessionDelegate ( ) ,
78
78
delegateQueue: nil
79
79
) )
80
-
81
- public static func sendRequest< T: RequestType > ( request: T , handler: ( Result < T . Response , APIError > ) -> Void = { r in } ) -> NSURLSessionDataTask ? {
80
+
81
+ public class var sharedSession : Session {
82
+ return privateSharedSession
83
+ }
84
+
85
+ public class func sendRequest< T: RequestType > ( request: T , handler: ( Result < T . Response , APIError > ) -> Void = { r in } ) -> NSURLSessionDataTask ? {
82
86
return sharedSession. sendRequest ( request, handler: handler)
83
87
}
84
88
85
- public static func cancelRequest< T: RequestType > ( requestType: T . Type , passingTest test: T -> Bool = { r in true } ) {
89
+ public class func cancelRequest< T: RequestType > ( requestType: T . Type , passingTest test: T -> Bool = { r in true } ) {
86
90
sharedSession. cancelRequest ( requestType, passingTest: test)
87
91
}
88
92
}
You can’t perform that action at this time.
0 commit comments