You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+8-6Lines changed: 8 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -183,19 +183,21 @@ class GitHub: API {
183
183
184
184
## Advanced usage
185
185
186
-
187
186
### NSURLSessionDelegate
188
187
189
-
APIKit creates singleton instances for each subclasses of API and set them as delegates of NSURLSession,
190
-
so you can add following features by implementing delegate methods.
188
+
You can add custom behaviors of `NSURLSession` by following steps:
189
+
190
+
1. Create a subclass of `URLSessionDelegate` (e.g. `MyAPIURLSessionDelegate`).
191
+
2. Implement additional delegate methods in it.
192
+
3. Override `defaultURLSession` of `API` and return `NSURLSession` that has `MyURLSessionDelegate` as its delegate.
193
+
194
+
This can add following features:
191
195
192
196
- Hook events of NSURLSession
193
197
- Handle authentication challenges
194
198
- Convert a data task to NSURLSessionDownloadTask
195
199
196
-
#### Overriding delegate methods implemented by API
197
-
198
-
API class also uses delegate methods of NSURLSession to implement wrapper of NSURLSession, so you should call super if you override following methods.
200
+
NOTE: `URLSessionDelegate` also implements delegate methods of `NSURLSession` to implement wrapper of `NSURLSession`, so you should call super if you override following methods.
0 commit comments