func createAlmsBoxParams(_ benefactorModel: BenefactorInformationsModel) -> [String: AnyObject]{
let general = General()
let array = [
"UserID": UserDefaults.standard.string(forKey: "userID")! as AnyObject,
"BenefactorMembersNo": benefactorModel.benefactorMembersNo as AnyObject,
"Gender": "true" as AnyObject,
"Firstname": benefactorModel.firstname as AnyObject,
"Lastname": benefactorModel.lastname as AnyObject,
"Alias": "Alias" as AnyObject,
"IdentityNo": benefactorModel.identityNo as AnyObject,
"PhoneNumber": benefactorModel.phoneNumber as AnyObject,
"PhoneRegionCode": benefactorModel.phoneRegionCode as AnyObject,
"PhoneCountryCode": benefactorModel.phoneCountryCode as AnyObject,
"Email": benefactorModel.email as AnyObject,
"Country": benefactorModel.country as AnyObject,
"City": benefactorModel.city as AnyObject,
"District": benefactorModel.district as AnyObject,
"RefDescription": benefactorModel.refDescription as AnyObject,
"Address": benefactorModel.address as AnyObject,
"EntityID": UserDefaults.standard.string(forKey: "entityID")! as AnyObject,
"EntityLevel": benefactorModel.entityLevel as AnyObject,
"DateOfBirth": "19700101" as AnyObject,
"Title": "Title" as AnyObject,
"Division": general.UniqueID() as AnyObject,
"Job": benefactorModel.job as AnyObject,
"IsBusiness": benefactorModel.isBusiness as AnyObject,
"Company": "Company" as AnyObject,
"IsMarried": benefactorModel.isMarried as AnyObject,
"Girl": 0 as AnyObject,
"Boy": 0 as AnyObject,
"Education": 28 as AnyObject,
"How_To_Contact_Us": 29 as AnyObject,
"Member_Type": 30 as AnyObject,
"Member_Grup": "sample string 31" as AnyObject,
"Member_Rank": 32 as AnyObject,
"Coordinate": benefactorModel.coordinate as AnyObject,
"Locked": true as AnyObject,
"Canceled": true as AnyObject,
"Deleted": true as AnyObject,
"IsHaveAlmsBox": true as AnyObject,
"fromWhere": 2 as AnyObject
]
return array as [String: AnyObject]
}
如何在此阵列中解决此问题?我尝试了很多方法
我尝试了什么 - >
let array:[String:AnyObject] = [“”:... as String(或Int,Double ect。)] ...
func createAlmsBoxParams() - > [String:Any] ......
我删除了所有参数附近的“as AnyObject”...
但未解决
答案 0 :(得分:2)
首先,它不是一个数组,它是一个字典。
其次,swift在处理像这样的巨大文字方面遇到了一些困难。你可以做的是定义一个var
字典并逐个放入条目:
var dictionary = [String: Any]()
dictionary["key1"] = value1
dictionary["key2"] = value2
//...