【发布时间】:2016-07-09 03:44:30
【问题描述】:
你能建议我如何在 swift 或 Objective c 中传递以下参数
let parameters = ["Access_Key":"0699DADD8A2B5FC2E8FF6FF5DDFE03EEDB3ED2132B29EA4F28","Packages":["Length":self.Length,"Type":"","Kg":self.Weight,"Height":self.Height,"Width":self.Width,"Name":self.SkuName],
"issignaturerequired":"true",
"Outputs":["LABEL_PNG_100X175"],
"DeliveryReference":"86882",
"Destination":["ContactPerson":self.CustomerFirstname,"Address":["PostCode":self.PostalCode,"StreetAddress":self.Address1,"Suburb":self.City,"BuildingName":"","City":self.City,"CountryCode":"AU"],"PhoneNumber":"","Email":self.CustomerEmail,"Name":self.CustomerFirstname],
"PrintToPrinter":"true",
"SendTrackingEmail":"",
"Commodities":["UnitKg":"1.0000","Currency":"NZD","Country":"NZ","Units":"1","Description":"Drums Drum Accessories Drum Bags","UnitValue":"44.0"],
"DeliveryInstructions":"None"
]
Alamofire.request(.POST, "http://api.omniparcel.com/labels/printcheapestcourier",parameters: parameters, encoding: .JSON)
.responseJSON { response in
print(response)
}
}
我是 iOS 新手
【问题讨论】:
-
对 Objective-C 使用“AFNetworking”,对 swift 使用“Alamofire”。你可以在 github 上找到这两个库
-
我知道,但你能建议我如何发布儿子编码参数
-
见$attachment参数
-
如果您将请求序列化程序设置为 JSON 并将其放入字典并作为参数传递,子 JSON 将其放入单独的字典中并将其设置为“Packages”键。我没有尝试过,但应该可以:)
-
类似 NSMutableDictionary *subJSon = ------ NSMutableDictionary *paramerters = @{@"Packages":subJson}
标签: ios objective-c json swift swift2