Skip to content

Commit

Permalink
Don't teardown the URLSession if it's the shared session - invalidati…
Browse files Browse the repository at this point in the history
…ng the shared session produces an error log
  • Loading branch information
joewalsh committed Oct 2, 2020
1 parent adf728b commit c6e3258
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Wikipedia/Code/Session.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,13 @@ public class Session: NSObject {
}

deinit {
defaultURLSession.invalidateAndCancel()
teardown()
}

@objc public func teardown() {
guard defaultURLSession !== URLSession.shared else { // [NSURLSession sharedSession] may not be invalidated
return
}
defaultURLSession.invalidateAndCancel()
defaultURLSession = URLSession.shared
}
Expand Down

0 comments on commit c6e3258

Please sign in to comment.