Skip to content

Instantly share code, notes, and snippets.

@boraseoksoon
Last active August 13, 2018 11:39
Show Gist options
  • Select an option

  • Save boraseoksoon/a652cc1223c48a2a5441cbd1d41fe01d to your computer and use it in GitHub Desktop.

Select an option

Save boraseoksoon/a652cc1223c48a2a5441cbd1d41fe01d to your computer and use it in GitHub Desktop.
string array to string for Dayz iOS
let mapStr = ["test"].reduce("", +)
mapStr
let mapStr2 = ["test"].joined()
mapStr2
let mapStr3 = ["test"].joined(separator: "")
mapStr3
extension String {
func removeDayzSearchCountSuffix() -> String {
if self.trimmingCharacters(in: .whitespacesAndNewlines).components(separatedBy: " (").count > 1 {
return self
.trimmingCharacters(in: .whitespacesAndNewlines)
.components(separatedBy: " (")
.dropLast()
.reduce("", +)
} else {
if self.last == " " {
return String(self.dropLast())
} else {
return self
}
}
}
}
let result3 = "audio ".removeSuffixSearchCountString()
result3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment