Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot invoke `join` with an argument list of type (String, [String]) in Swift 2.0

Tags:

swift

swift2

var specializationTitles = ["a", "b", "c", "d"]
let outputString = join(" / ", specializationTitles)

got an error:

Cannot invoke join with an argument list of type (String, [String])

How to solve this?

like image 737
Bartłomiej Semańczyk Avatar asked Jun 26 '15 09:06

Bartłomiej Semańczyk


2 Answers

let separator = " / "
let outputString = separator.join(specializationTitles)

With Xcode7beta6:

specializationTitles.joinWithString(" / ")

With Xcode7 release version:

specializationTitles.joinWithSeparator(" / ")
like image 196
Bartłomiej Semańczyk Avatar answered Nov 10 '22 05:11

Bartłomiej Semańczyk


In Swift 2.0 ( which is default on Xcode 7), you will have to use, joinWithSeparator

specializationTitles.joinWithSeparator(" / ")
like image 2
Nagendra Rao Avatar answered Nov 10 '22 07:11

Nagendra Rao