Wednesday 15 January 2014

swift How to remove optional String Character -



swift How to remove optional String Character -

how remove optional character

let color = colorchoicesegmentedcontrol.titleforsegmentatindex(colorchoicesegmentedcontrol.selectedsegmentindex) println(color) // optional("red") allow imageurlstring = "http://hahaha.com/ha.php?color=\(color)" println(imageurlstring) //http://hahaha.com/ha.php?color=optional("red")

i want output "http://hahaha.com/ha.php?color=red"

how can?

hmm....

actually when define variable optional need disclose optional value. prepare problem either have declare variable non alternative or set !(exclamation) mark behind variable disclose alternative value.

var temp : string? // optional. temp = "i programer" println(temp) // optional("i programer") var temp1 : string! // not optional. temp1 = "i programer" println(temp1) // "i programer"

string swift

No comments:

Post a Comment