I am using the following code in xCode 6.4 to split strings inside an array into arrays:
func getData() -> [String]
{
let data = navData
// navData is like:
// A|xxx|xxx|xxx
// R|ccc|ccc|ccc
// N|ccc|ccc|ccc
// N|ccc|ccc|ccc
return split(data) { $0 == "\n" }
}
let data:[String] = getData()
func search(query:(String, Int)) -> [String]
{
let recs:[String] = data.filter { $0.hasPrefix(query.0) }
var cols: [String] = recs.map { split( recs ) { $0 == "|" } }
}
func searchQueries() -> [(String, Int)]
{
return [("N", 1)] //key, column index
}
for q:(String, Int) in searchQueries()
{
var results:[String] = search(q)
for x in results
{
result = results[0]
}
}
It used to work before, but I guess swift was changed in 1.2 and it gives the following error now:
Cannot invoke 'map' with an argument list of type '(() -> _)'
Any suggestions?
Thank you!
datalooks something like["abc|def", "ghi|jkl"].[N|ccc|ccc|ccc,N|ccc|ccc|ccc]