【发布时间】:2016-08-30 11:11:05
【问题描述】:
如何将空 JSON 字符串传递给 Alamofire 并发送 POST 请求?
我试过这样:
let lazyPojo = LazyPojo()
let JSONString = Mapper<LazyPojo>().map(lazyPojo)
Alamofire.request(.POST, url, JSONString, encoding:.JSON).validate()
.responseJSON{...}
它说我的JSONString 必须被解包,但是当我运行它时,我得到了这个错误:fatal error: unexpectedly found nil while unwrapping an Optional value。
这怎么可能?
【问题讨论】:
-
Alamofire.request(.POST, url, parameters: [ ], encoding:.JSON).validate() .responseJSON{...} pass [ ] 作为参数
-
但我需要传递映射的“lazy pojo”,这样我的服务器才能识别它并做一些特定的事情。
-
参数名是什么?
-
抱歉代码不好,但现在我编辑它。所以我需要传递一个 JSONString 作为参数。
-
您正在传递 JSONString ,这就是值,但是您传递的值的参数名称是什么?您没有提到值的参数名称