小编Aki*_*zen的帖子

Swift 4使用带有多个参数的选择器

我用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方法。

selector swift3 swift4

7
推荐指数
1
解决办法
7171
查看次数

JSON 解码器类型不匹配错误

我想使用 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)

parsing json decoder ios swift

1
推荐指数
1
解决办法
1836
查看次数

标签 统计

decoder ×1

ios ×1

json ×1

parsing ×1

selector ×1

swift ×1

swift3 ×1

swift4 ×1