gpt4 book ai didi

ios - swift 3 [字符串 : AnyObject] Expression was too complex Error

转载 作者:行者123 更新时间:2023-11-28 12:38:33 27 4
gpt4 key购买 nike

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(or Int, Double ect.)]...

func createAlmsBoxParams() -> [String: Any] ...

I deleted "as AnyObject" near by all parameters ...

但没有解决

最佳答案

首先,它不是一个真正的数组,它是一个字典。

其次,swift 在处理像这样的巨大文字时遇到了一些困难。您可以做的是定义一个 var 字典并一个一个地放置条目:

var dictionary =  [String: Any]()
dictionary["key1"] = value1
dictionary["key2"] = value2
//...

关于ios - swift 3 [字符串 : AnyObject] Expression was too complex Error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40148741/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com