how to pass a nil value for one of the parameter in alamofire Post request

后端 未结 4 1304
不思量自难忘°
不思量自难忘° 2021-01-17 16:02

I would like to pass a nil value i.e., optional to one of the parameter value. And it must proceed with the nil value in the Alamofire Post request .It woul

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-17 16:42

    By passing nil or uninitialized optional parameter Server will get Optional

    You can pass NSNull() to dictionary

    try this, like

    var params = ["paramA","valueA"] if imageBase64 == nil {   parms["image"] = NSNull()} else {   params["image"] = imageBase64 }
    

    swiftyjson also handle null as NSNull

    also there is good reference here null / nil in swift language

提交回复
热议问题