简体   繁体   中英

Updating to Swift 3.0: Contextual type 'AnyObject' cannot be used with dictionary literal

Im updating my codebase to Swift 3.0, and I cannot figure out how to fix the error I am generating when migrating: "Contextual type 'AnyObject' cannot be used with dictionary literal". Any help would be greatly appreciated.

typealias JSONDictionary = Dictionary<String, AnyObject>

func infoDict() -> JSONDictionary {
    return ["users" :
        //the following line generates the error "Contextual type 'AnyObject' cannot be used with dictionary literal"
        ["add" : Array(self.addUserIDs), "del" : Array(self.removeUserIDs)],
            "groups" :
                ["add" : Array(self.addCircleIDs), "del" : Array(self.removeCircleIDs)],
            "friends" : friends,
            "type" : 1
    ]
}

AnyObject在Swift 3中已更改为Any

typealias JSONDictionary = Dictionary<String, Any>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM