我用Swift 4编写并尝试编写一个将categoryId作为操作发送的函数,但是我无法编写。我认为我的语法是错误的。您能说说如何使用选择器吗?
@objc func sendCategoryIdToPackageSelectionVC(categoryId : Int){
MarketVC.categoryId = categoryId
self.performSegue(withIdentifier: "sequeGoToPackageSelection", sender: nil)
}
func addTapFeatures(){
taplabel1 = UITapGestureRecognizer(target: self, action: #selector(self.sendCategoryIdToPackageSelectionVC(categoryId:2)))
taplabel1?.cancelsTouchesInView = false
self.labelFirst.addGestureRecognizer(taplabel1!)
}
Run Code Online (Sandbox Code Playgroud)
我收到一个错误消息,说操作选择器未引用任何objc方法。
我想使用 decodeable 解析 JSON,但我得到一个错误类型不匹配,例如:
Swift.DecodingError.Context(codingPath: [], debugDescription: "预期解码数组,但找到了字典。"
我的 JSON :
{
"code": 0,
"data": {
"_id": "string",
"title": "string",
"images": [
"string"
],
"shortDesc": "string",
"desc": "string",
"price": 0,
"discountPrice": 0,
"quantity": 0,
"category": {
"name": "string",
"val": "string"
},
"brand": {
"name": "string",
"val": "string"
},
"variants": [
{
"name": "string",
"value": "string",
"quantity": 0,
"variantCode": "string"
}
],
"stockCode": "string",
"updatedDate": "2018-06-05T14:04:51.226Z",
"status": true,
"isDeleted": true,
"isNew": true,
"freeCargo": true,
"createDate": "2018-06-05T14:04:51.226Z",
"note1": "string",
"note2": "string",
"note3": …Run Code Online (Sandbox Code Playgroud)