Updated to Xcode 6.3.1 with new Swift 1.2, the old method countElement
change to count
, however when I switch to use count
, it always throw out this error message:
cannot invoke 'count' with an argument list of type '(String)'
This snippet is I copied from Apple doc, but still not working.
func printAndCount(stringToPrint: String) -> Int {
println(stringToPrint)
return count(stringToPrint)
}
func printWithoutCounting(stringToPrint: String) {
printAndCount(stringToPrint)
}
printAndCount("hello, world")
Try calling the global count
function with the Swift
module prefix like this:
Swift.count(stringToPoint)
E.g. when extending the Array type there is a property named count as well and thus there is a naming conflict.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With