Reputation: 26652
In implementing fallback instance methods for methods using @available(iOS 8.0, *)
, Xcode shows a built error:
"Ambiguous use of 'myMethod'...
along with two candidate methods highlighted.
This is despite using the @available
directive.
For example:
@available(iOS 8.0, *)
func getURLParameter() -> NSURLQueryItem
{
return NSURLQueryItem(name: "name", value: "John")
}
func getURLParameter() -> Dictionary<String, String>
{
return ["name" : "John"]
}
let param = getURLParameter()
The @available
works successfully elsewhere with methods identically named. Why does it fail in this case?
Upvotes: 2
Views: 385
Reputation: 12015
Above or equal to iOS 8, both getURLParameter
methods are available, and if you declare your param
variable without type, the compiler will not be able the choose between the methods.
Upvotes: 2