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-6
Original file line number
Diff line number
Diff line change
@@ -169,19 +169,21 @@ class GitHub: API {
169
169
170
170
## Advanced usage
171
171
172
-
173
172
### NSURLSessionDelegate
174
173
175
-
APIKit creates singleton instances for each subclasses of API and set them as delegates of NSURLSession,
176
-
so you can add following features by implementing delegate methods.
174
+
You can add custom behaviors of `NSURLSession` by following steps:
175
+
176
+
1. Create a subclass of `URLSessionDelegate` (e.g. `MyAPIURLSessionDelegate`).
177
+
2. Implement additional delegate methods in it.
178
+
3. Override `defaultURLSession` of `API` and return `NSURLSession` that has `MyURLSessionDelegate` as its delegate.
179
+
180
+
This can add following features:
177
181
178
182
- Hook events of NSURLSession
179
183
- Handle authentication challenges
180
184
- Convert a data task to NSURLSessionDownloadTask
181
185
182
-
#### Overriding delegate methods implemented by API
183
-
184
-
API class also uses delegate methods of NSURLSession to implement wrapper of NSURLSession, so you should call super if you override following methods.
186
+
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