Reputation: 7067
This code was compiling on Xcode 8 beta 5 but broken in beta 6. What is the right new Swift 3 way to do this comparison?
self.categories = categories.sorted { $0.localizedCaseInsensitiveCompare($1) == ComparisonResult.orderedDescending }
The error is
Argument passes to call that takes no arguments
Upvotes: 1
Views: 1120
Reputation: 1121
Same issue here. I tried to compile a snippet from the official Swift 3 guide in Xcode beta and got the same error - Argument passes to call that takes no arguments
. Though, when I used IBM Swift Sandbox, it compiled successfully.
let names = ["Chris", "Alex", "Ewa", "Barry", "Daniella"]
func backward(_ s1: String, _ s2: String) -> Bool {
return s1 > s2
}
var reversedNames = names.sorted(by: backward)
From looking here, it seems that the API of sorted changed from x.sorted(isOrderedBefore: >) to x.sorted(by: >). I guess that in the future Xcode beta, this will be taken care of.
Upvotes: 1
Reputation: 47886
I just have succeeded to get the same error message.
In my testing code, if I declare the instance property categories
as:
var categories: [NSString] = []
I have got this error message:
error: argument passed to call that takes no arguments
If your case is very similar to this, you need to change the property declaration to:
var categories: [String] = []
Even if this does not fit for your issue, you'd better check this sort of type-mismatching, because as of Swift 3/Xcode 8 beta 6:
- Bridging conversions are no longer implicit. The conversion from a Swift value type to its corresponding object can be forced with
as
. For example:string as NSString
. Any Swift value can also be converted to its boxedid
representation withas AnyObject
. (SE-0072)
(Taken from the Release Notes of Xcode 8 beta 6.)
Upvotes: 1