swift - 在 alamofire 中通过 POST 传递复杂参数

标签 swift xcode

let newTodo  =  [
    "currentPageNo" :  (page.description) ,
    "type": "basic_search",
    "searchParams": [
                        "remember_search" : checkk ,
                        "u_seeking": (bsMatch_looking) ,
                        "age_from" :  (bsMatch_agefrom) ,
                        "age_to": (bsMatch_ageto),
                        "u_looking_for_value" :(bsMatch_lookingfoevalue),
                        "u_country": (bsMatch_country) ,
                        "u_state" :  (bsMatch_ustate) ,
                        "u_city": (bsMatch_city) ,
                        "u_postalcode" :  (bsMatch_postelcode) ,
                        "distance": (bsMatch_distance) ,
                     ]                
                ] as [String : AnyObject]

响应如下

["type": basic_search , "currentPageNo": 1 ,"searchParams": {
"age_from" = 18;
"age_to" = 44;
distance = 0;
"remember_search" = On;
"u_city" = "";
"u_country" = 1;
"u_looking_for_value" = 0;
"u_postalcode" = "";
"u_seeking" = Female;
"u_state" = California;
}]

但是我想要这种类型的响应,我该怎么做,只有黄铜才会给我带来问题,请为我提供解决方案

[{ "currentPageNo": 1, "type": basic_search ,"searchParams": {
"age_from" = 20;
"age_to" = 35;
distance = 100;
"remember_search" = On;
"u_city" = London;
"u_country" = 222;
"u_looking_for_value" = "0";
"u_postalcode" = "";
"u_seeking" = Male;
"u_state" = England;
}}]

我想将第一个代码转换为第二个类型

最佳答案

您可以通过使用 Int 类型的键来订购它们。

var myDictionary: [Int: [String: String]]?

关于swift - 在 alamofire 中通过 POST 传递复杂参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57460185/

相关文章:

ios - 使用 spritekit 为 2d 平台游戏添加移动平台的轻松进出

ios - 你能帮忙解决 data.entry.init 问题吗?

iphone - 如何构建 iPhone Xcode 项目?

ios - 我应该如何设计图像大小以支持所有 iOS 设备 Retina 显示

ios - iBeacon 技术将位置感知应用程序访问锁屏

ios - Swift - 单独的 View 有共享相同内存的 subview ?

ios - 如何弹出回到不同导航 Controller 中的 View ?

ios - 使用 iTunes 恢复备份安装相同应用程序的两个 iOS 设备的identifierForVendor 可以相同吗?

c++ - 尝试在 Mac 上编译 GLFW 时 GLFW 上的链接器错误

iphone - 如何在 iPhone 中将图像从相机/UIImagePickerController 动态添加到 iCarousel