var people = [Mydata]()
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "thereSegue" ,
let destinationNavigationController = segue.destination as? UINavigationController ,
let nextScene = destinationNavigationController.topViewController as? commentView ,
let indexPath = self.myTable.indexPathForSelectedRow {
let selectedVehicle = people[indexPath.row]
nextScene.postId = (selectedVehicle.value(forKey: "iD") as? String)!
print(nextScene.postId)
nextScene.postType = (selectedVehicle.value(forKey: "pTYPE") as? String)!
print(nextScene.postType)
}
}
当我尝试
时let jsonUrl = "https://www.zdoof.com/api/zTimeline/add_post_comment?"
let jsonUrlWithParameters = jsonUrl + "Comment=\(String(describing: self.commentText.text!))" + "&Post_id=\(postId)" + "&Post_type=\(postType)" + "&Created_by=4490" + "&Created_on=\(joinString)"
print(jsonUrlWithParameters)
正在打印
可选(8167)
可选(1)
那么如何删除"可选"
答案 0 :(得分:0)
简单地说!在您想要解包的可选值之后。
例如:
var integer: Int? = 5
print(integer) // would print out Optional(5)
print(integer!) // would print out 5
你应该小心;而是使用
if let unwrappedValue = integer {
print(unwrappedValue)
}
如果该值不是可选的,则仅打印出该值。