Reputation: 1083
I am unable to return an array from a function call in Swift.
The script is a little bit longer now and little complicated as well, but this is basically what the output from within the function would look like:
func getRecentUpdates()
{
var updates = [("test", "hello"),("nice", "one")]
println(updates)
return updates
}
println displays the array in the console but with the return
, an error says NSArray() is not convertible to ()
Upvotes: 2
Views: 3314
Reputation: 777
specter's update for swift 4:
func getRecentUpdates()-> Array<[String]>{
let updates = [("test", "hello"),("nice", "one")]
return updates
}
Upvotes: 0
Reputation: 777
This should work:
func getRecentUpdates()->[(String,String)]
{
let updates = [("test", "hello"),("nice", "one")]
return updates
}
Upvotes: 6