TimeInterval - seconds(_ secondsCount: Int) -> TimeInterval
tatunn opened this issue Β· comments
Describe the bug π
You have an extension about TimeInterval which has a method seconds(_:) -> TimeInterval
this method already exists
public extension TimeInterval {
static let second: TimeInterval = 1
static func seconds(_ secondsCount: Int) -> TimeInterval {
return TimeInterval(secondsCount)
}
}
To Reproduce π
Steps to reproduce the behavior:
- Go to '...'
- Click on '....'
- Scroll down to '....'
- See error
Expected behavior π
A clear and concise description of what you expected to happen.
Screenshots π₯
If applicable, add screenshots to help explain your problem.
Environment:
- OS: [e.g. iOS]
- Version [e.g. 22]
Additional context
Add any other context about the problem here.
Hi @tatunn,
I didn't manage to find this method in the standard library. Could you provide more details?
Hello, it conflicts with DispatchTimeInterval.seconds
, so when a library is connected we need to specify, which type to use. For example, the next code produces error ambiguous use of init
, if the library is connected. (Xcode version 12.5)
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(1)) {
// Some code
}
So the fix is to specify the type manually. However, I suppose, that the extension of the TimeInterval shouldn't be public.
DispatchQueue.main.asyncAfter(deadline: .now() + DispatchTimeInterval.seconds(1)) {
}