细分错误:Xcode 10

时间:2018-10-10 11:17:04

标签: swift xcode xcode10

所以我只更新最新的Xcode版本。在9.4.1上,似乎还不错。但是,当我将其升级到10后,出现了一个错误,提示“细分错误:11”。这是日志:

  
      
  1. 在/ Users / wmotionmac / Project / Wmotion / WWF Content Manager / WWF Content Manager / Model / Api / Api.swift:273:5 < / li>   
  2. silgen发出Function SIL函数“ @ $ S19WWF_Content_Manager17DetailActivityApiV21insertOrUpdateChannel8activity7channel4user10completionyAA0E0C_AA0J0CAA4UserCySbctFZ”时。   在/ Users / wmotionmac / Project / Wmotion / WWF Content Manager / WWF Content Manager / Model / Api / Api.swift:273:5中的'insertOrUpdateChannel(activity:channel:user:completion :)'   错误:细分错误:11
  3.   

这是insertOrUpdateChannel的代码

//TODO:- Create or Update Channel
static func insertOrUpdateChannel(activity: Activity, channel: Channel, user: User, completion: @escaping(Bool)->()) {
    let url = URL(string: Base.api + "/channelactivitypage?calendarId=\(activity.id)")
    var request = URLRequest(url: url!)
    if channel.id.elementsEqual("") {
        request.httpMethod = "POST"
    } else {
        request.httpMethod = "PUT"
    }
    request.setValue("application/json", forHTTPHeaderField: "Content-Type")

    var tema = [String : Int]()
    var themes = [[String : Int]]()
    var assets = [[String : Any]]()
    let email = ["ID": String(describing: "2c53ea1f-6ebe-e811-a977-000d3aa00fc2"), "Name": String(describing: "TV Broadcast"), "List_EmailListModels": nil]

    for theme in channel.themes {
        if !theme.elementsEqual("") {
            tema = ["Value" : Int(theme)!]
            themes.append(tema)
        } else {
            tema = ["Value" : -1]
            themes.append(tema)
        }
    }

    if channel.digitalAsset.count > 0 {
        for asset in channel.digitalAsset {
            let media = ["ID" : asset.id, SerializationKeys.name : asset.name, SerializationKeys.description : asset.description, SerializationKeys.copyRightCredit : asset.copyRightCredit, SerializationKeys.location : asset.location]
            assets.append(media)
        }
    } else {
        let media = [SerializationKeys.name : "", SerializationKeys.description : "", SerializationKeys.copyRightCredit : "", SerializationKeys.location : ""]
        assets.append(media)
    }

    let parameters = [["ID" : channel.id, SerializationKeys.name : activity.activityName, SerializationKeys.channelType : channel.channelType, SerializationKeys.publish_date : "2018-09-21T01:00:00Z", "Headline" : channel.headline, SerializationKeys.content : channel.content, SerializationKeys.emailSubject : channel.emailSubject, SerializationKeys.emailURL : channel.emailURL, SerializationKeys.mention : channel.mention, "PostLink" : channel.postLink, SerializationKeys.channelMobileId : channel.mobileId, "Hastag" : nil, SerializationKeys.tema : themes, SerializationKeys.emailGroup : [email], "ApprovalStatus" : channel.channelStatus, SerializationKeys.rubric : channel.rubric, "ApprovalNote" : channel.note, "DigitalAsset" : assets, "ApprovalEmployeeId" : user.id, "ApprovalEmployeeLevel" : user.level]] as [[String : Any]]
    request.httpBody = try! JSONSerialization.data(withJSONObject: parameters, options: .prettyPrinted)

    Alamofire.request(request).responseJSON { (response) in
        switch response.result {
        case .success:
            let json = JSON(response.result.value!)
            if !json["Message"].stringValue.elementsEqual("") {
                completion(false)
            } else {
                 completion(true)
            }
        case .failure(_):
            completion(false)
        }
    }
}

这是DetailActivity的代码

DetailActivityApi.insertOrUpdateChannel(activity: self.activity!, channel: channel, user: self.user!) { (isSuccess) in
                            if isSuccess {
                                DetailActivityApi.updateDetailActivity(activity: self.activity!, user: self.user!) { (error) in
                                    if error != nil {
                                        print(error!)
                                        Message.connectionFailed()
                                        Loading.hide()
                                    } else {

                                    }
                                }
                                self.db.deleteChannelData(id: id, completion: { (isSucceed) in
                                    if isSucceed {
                                        if let digitalAsset = data {
                                            self.db.deleteAsset(id: digitalAsset[self.db.ID]) { (_) in

                                            }
                                        }

                                        self.navigationController?.popViewController(animated: true)
                                        self.dismiss(animated: true, completion: nil)
                                        Message.custom(title: "Submit", body: "Send activity to server", type: .success)
                                    } else {

                                    }
                                })
                            }
                        }
                        Loading.hide()

1 个答案:

答案 0 :(得分:0)

好的,最后,我在朋友的帮助下找到了解决方案。我的代码中有一个错误,更改后,结果如下

static func insertOrUpdateChannel(activity: Activity, channel: Channel, user: User, completion: @escaping(Bool)->()) {
    let url = URL(string: Base.api + "/channelactivitypage?calendarId=\(activity.id)")
    var parameters: [[String : Any?]] = []
    var request = URLRequest(url: url!)
    if channel.id.elementsEqual("") {
        request.httpMethod = "POST"
    } else {
        request.httpMethod = "PUT"
    }
    request.setValue("application/json", forHTTPHeaderField: "Content-Type")

    var tema = [String : Int]()
    var themes = [[String : Int]]()
    var assets = [[String : Any]]()
    let email = ["ID": String(describing: "2c53ea1f-6ebe-e811-a977-000d3aa00fc2"), "Name": String(describing: "TV Broadcast"), "List_EmailListModels": nil]

    for theme in channel.themes {
        if !theme.elementsEqual("") {
            tema = ["Value" : Int(theme)!]
            themes.append(tema)
        } else {
            tema = ["Value" : -1]
            themes.append(tema)
        }
    }

    if channel.digitalAsset.count > 0 {
        for asset in channel.digitalAsset {
            let media = ["ID" : asset.id, SerializationKeys.name : asset.name, SerializationKeys.description : asset.description, SerializationKeys.copyRightCredit : asset.copyRightCredit, SerializationKeys.location : asset.location]
            assets.append(media)
        }
    } else {
        let media = [SerializationKeys.name : "", SerializationKeys.description : "", SerializationKeys.copyRightCredit : "", SerializationKeys.location : ""]
        assets.append(media)
    }
    let params = ["ID" : channel.id, SerializationKeys.name : activity.activityName, SerializationKeys.channelType : channel.channelType, SerializationKeys.publish_date : "2018-09-21T01:00:00Z", "Headline" : channel.headline, SerializationKeys.content : channel.content, SerializationKeys.emailSubject : channel.emailSubject, SerializationKeys.emailURL : channel.emailURL, SerializationKeys.mention : channel.mention, "PostLink" : channel.postLink, SerializationKeys.channelMobileId : channel.mobileId, "Hastag" : nil, SerializationKeys.tema : themes, SerializationKeys.emailGroup : [email], "ApprovalStatus" : channel.channelStatus, SerializationKeys.rubric : channel.rubric, "ApprovalNote" : channel.note, "DigitalAsset" : assets, "ApprovalEmployeeId" : user.id, "ApprovalEmployeeLevel" : user.level] as [String : Any?]

    parameters.append(params)
    request.httpBody = try! JSONSerialization.data(withJSONObject: parameters, options: .prettyPrinted)

    Alamofire.request(request).responseJSON { (response) in
        switch response.result {
        case .success:
            let json = JSON(response.result.value!)
            if !json["Message"].stringValue.elementsEqual("") {
                completion(false)
            } else {
                 completion(true)
            }
        case .failure(_):
            completion(false)
        }
    }
}