小编Pra*_*mar的帖子

如何为alamofire Post请求中的一个参数传递一个nil值

我想传递一个nil值,即可选参数值之一.并且必须在Alamofire Post请求中继续使用nil值.如果你告诉我下一步该如何进行会有所帮助吗?

    let image: UIImage = UIImage()
    let imageData = UIImagePNGRepresentation(image)
    let base64String = imageData?.base64EncodedStringWithOptions(.Encoding64CharacterLineLength)

    let parameters = [
        "first_name": "XXXXX",
        "email" : "1234@gmail.com",
        "password" : "password",
        "profile_picture" : base64String]

Alamofire.request(.POST, "http://abc/public/user/register", parameters: parameters, encoding: .JSON, headers: nil)

        .progress { bytesWritten, totalBytesWritten, totalBytesExpectedToWrite in
            print(totalBytesWritten)

            // This closure is NOT called on the main queue for performance
            // reasons. To update your ui, dispatch to the main queue.
            dispatch_async(dispatch_get_main_queue()) {
                print("Total bytes written on main queue: \(totalBytesWritten)")
           } …
Run Code Online (Sandbox Code Playgroud)

parameters post swift alamofire

10
推荐指数
2
解决办法
5364
查看次数

标签 统计

alamofire ×1

parameters ×1

post ×1

swift ×1