程式如下
override func viewDidLoad() {
super.viewDidLoad()
//var ProductNoArray = shoppingCarData.GoodsInfo.allKeys
var tDictionary = [String:String]()
var tnum:Int = 0
for i in shoppingCarData.GoodsInfo {
tnum = i.object(forKey: "num") as! Int
tDictionary[i.object(forKey: "productno") as! String] = String(tnum)
}
let paramters = [
"type":"do_order",
"custno":UserInfoDictionary["CustNo"] as String!,
"r_name":r_name,
"r_phone":r_phone,
"r_city":r_city,
"r_address":r_address,
"r_zip":r_zip,
"total":shoppingCarData.TotalInt,
"payment":shoppingCarData.PaymentInt,
"shopwaypay":shoppingCarData.ShipWayPayInt,
"discount":shoppingCarData.DiscountInt,
//"shopway":shoppingCarData.ShipWayArray[shoppingCarData.ShipWayType],
"shipwaytype":shoppingCarData.ShipWayType,
"subtotal":shoppingCarData.SubTotalInt,
"subtotalafterdiscount":shoppingCarData.SubTotalAfterDiscountInt,
"CVSStoreID":CVSStoreID,
"CVSAddress":CVSAddress,
"CVSStoreName":CVSStoreName,
"productnoarry":tDictionary,
"savepersoninfobool":SavePersonalInfoBool,
"savecreditcardinfobool":SaveCreditCardInfoBool,
"be_invoice":BeInvoiceBool,
"creditcardno":CreditCardInfoDictionary["CreditCardNo"],
"creditname":CreditCardInfoDictionary["Name"],
"creditmobile":CreditCardInfoDictionary["mobile"],
"taxid":TaxInfoDictionary["taxid"],
"taxtitle":TaxInfoDictionary["title"],
"taxzip":TaxInfoDictionary["zip"],
"taxaddress":TaxInfoDictionary["address"],
"taxcity":TaxInfoDictionary["city"],
"taxarea":TaxInfoDictionary["area"],
"numarry":tDictionary
] as! [String:Any?]
print(paramters)
Alamofire.request(Config.val.AJAXURL, method: .post, parameters: paramters, encoding: URLEncoding.default).responseJSON { response in
myFunc.MYFUNC.hideActivityIndicatory()
print(response.result.value)
if response.result.isFailure {
myFunc.MYFUNC.showAlertWithMessage("交易失敗")
return
}
print(response.result.value)
}
// Do any additional setup after loading the view.
}
只要把 以下的 paramtes 给 mark掉,或是删除部份的元素 ,编译的时间就会缩短
请问以下的这段我要怎么改
这是 Swift compiler 的一个老问题了,自动类型推导引起的bug。
改成:
应该会好很多。另外,class里的属性加上 self 也能提高编译器的工作性能。