Skip to content

Commit 3fffd22

Browse files
Merge pull request #5 from readdle/fix/fix-url-session-behaviour-task-fatal
URLSession fixes
2 parents 26f6fb4 + 9e954e0 commit 3fffd22

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

Foundation/NSString.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ func NSLocalizedString(_ key: String,
2727
bundle: Bundle = Bundle.main,
2828
value: String = "",
2929
comment: String) -> String {
30-
return bundle.localizedString(forKey: key, value: value, table: tableName)
30+
#if os(Android)
31+
return key
32+
#else
33+
return bundle.localizedString(forKey: key, value: value, table: tableName)
34+
#endif
3135
}
3236

3337
#if os(OSX) || os(iOS)

Foundation/URLSession/TaskRegistry.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,8 @@ extension URLSession._TaskRegistry {
115115
}
116116
return b
117117
}
118+
119+
func containsBehaviour(for task: URLSessionTask) -> Bool {
120+
return behaviours[task.taskIdentifier] != nil
121+
}
118122
}

Foundation/URLSession/URLSession.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,10 @@ internal extension URLSession {
546546
}
547547

548548
func behaviour(for task: URLSessionTask) -> _TaskBehaviour {
549+
guard taskRegistry.containsBehaviour(for: task) else {
550+
return .noDelegate
551+
}
552+
549553
switch taskRegistry.behaviour(for: task) {
550554
case .dataCompletionHandler(let c): return .dataCompletionHandler(c)
551555
case .downloadCompletionHandler(let c): return .downloadCompletionHandler(c)

0 commit comments

Comments
 (0)