anyobject

type any? has no subscript members

我是研究僧i 提交于 2019-11-27 09:14:37
I want to get Addresses from profile dictionary,but I got the error "type any? has no subscript members" var address:[[String : Any]] = [["Address": "someLocation", "City": "ABC","Zip" : 123],["Address": "someLocation", "City": "DEF","Zip" : 456]] var profile:[String : Any] = ["Name": "Mir", "Age": 10, "Addresses": address] profile["Addresses"][0] <-----------------type any? has no subscript members How can I fix it and get the address? Thanks a lot. When you subscript profile with "Addresses" , you're getting an Any instance back. Your choice to use Any to fit various types within the same

type any? has no subscript members

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 12:19:33
问题 I want to get Addresses from profile dictionary,but I got the error \"type any? has no subscript members\" var address:[[String : Any]] = [[\"Address\": \"someLocation\", \"City\": \"ABC\",\"Zip\" : 123],[\"Address\": \"someLocation\", \"City\": \"DEF\",\"Zip\" : 456]] var profile:[String : Any] = [\"Name\": \"Mir\", \"Age\": 10, \"Addresses\": address] profile[\"Addresses\"][0] <-----------------type any? has no subscript members How can I fix it and get the address? Thanks a lot. 回答1: When