Skip to content

Commit

Permalink
Merge pull request #30 from hirad/fix-exhaustive-DispatchTimeInterval…
Browse files Browse the repository at this point in the history
…-switch

fix exhaustive switch error in Xcode 9
  • Loading branch information
mdiep authored Jul 15, 2017
2 parents 5b643a6 + 19a5b0a commit 332f39d
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions ReactiveObjCBridge/ObjectiveCBridging.swift
Original file line number Diff line number Diff line change
Expand Up @@ -486,15 +486,30 @@ public func bridgedTuple<First, Second, Third, Fourth, Fifth>(from tuple: RACFiv

extension DispatchTimeInterval {
fileprivate var timeInterval: TimeInterval {
switch self {
case let .seconds(s):
return TimeInterval(s)
case let .milliseconds(ms):
return TimeInterval(TimeInterval(ms) / 1000.0)
case let .microseconds(us):
return TimeInterval(UInt64(us) * NSEC_PER_USEC) / TimeInterval(NSEC_PER_SEC)
case let .nanoseconds(ns):
return TimeInterval(ns) / TimeInterval(NSEC_PER_SEC)
}
#if swift(>=3.2)
switch self {
case let .seconds(s):
return TimeInterval(s)
case let .milliseconds(ms):
return TimeInterval(TimeInterval(ms) / 1000.0)
case let .microseconds(us):
return TimeInterval(Int64(us) * Int64(NSEC_PER_USEC)) / TimeInterval(NSEC_PER_SEC)
case let .nanoseconds(ns):
return TimeInterval(ns) / TimeInterval(NSEC_PER_SEC)
case .never:
return .infinity
}
#else
switch self {
case let .seconds(s):
return TimeInterval(s)
case let .milliseconds(ms):
return TimeInterval(TimeInterval(ms) / 1000.0)
case let .microseconds(us):
return TimeInterval(Int64(us) * Int64(NSEC_PER_USEC)) / TimeInterval(NSEC_PER_SEC)
case let .nanoseconds(ns):
return TimeInterval(ns) / TimeInterval(NSEC_PER_SEC)
}
#endif
}
}

0 comments on commit 332f39d

Please sign in to comment.