algolia / algoliasearch-client-swift

⚑️ A fully-featured and blazing-fast Swift API client to interact with Algolia.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. 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)) {

}