PubNub 使用,Swift 2.0 更新 "Ambiguous use of 'subscript'" + "Sorted"

PubNub usage, Swift 2.0 update "Ambiguous use of 'subscript'" + "Sorted"

func client(client: PubNub, didReceiveMessage message: PNMessageResult) {
    if message.data.subscribedChannel == self.channel {
        if let messageInfo: AnyObject = message.data.message {
            let type = (messageInfo["type"] as! String) //Ambiguous use of 'subscript'
            let date = (messageInfo["date"] as! String).getDateString() //Ambiguous use of 'subscript'
            let messageText = messageInfo["message"] as! String //Ambiguous use of 'subscript'
            let fileUrl: String? = type == "text" ? nil : "http://college.audio-visueel.com/" + (messageInfo["fileUrl"] as! String)
            let from: ConversationMessage.sendFromType = (messageInfo["userID"] as! String) == self.userID ? .Me : .Other //Ambiguous use of 'subscript'
            let image = messageInfo["userPhoto"] as! String //Ambiguous use of 'subscript'
            let name = messageInfo["userName"] as! String //Ambiguous use of 'subscript'
            if data[date] != nil {
                data[date]!.append(ConversationMessage(userID: messageInfo["userID"] as! String,text: messageText, from: from, personImage: image, personName: name, date: messageInfo["date"] as! String, type: type, fileUrl: fileUrl))
            } else {
                data[date] = [ConversationMessage(userID: messageInfo["userID"] as! String,text: messageText, from: from, personImage: image, personName: name, date: messageInfo["date"] as! String, type: type, fileUrl: fileUrl)]
            }
            for section in self.sections {
                self.data[section]! = sorted(self.data[section]!) { Utils.compareDateTime([=13=].date, with: .date, order: .OrderedAscending) //'sorted' is unavailable: call the 'sort()' method on the collection}
            }
            searchedSections = sections
            searchedData = data
            tableView.reloadData()
            tableViewScrollToBottom(false)
        }
    }
}

正如我从 PubNub 更新中了解到的那样……我不明白!!!请帮我找出问题所在,为什么?

还有 对成员 'client'

的引用不明确
    client.historyForChannel(channel, start: nil, end: nil, limit: 10, withCompletion: {
        (result: PNHistoryResult , status: PNErrorStatus ) -> Void in
        let messages = result.data.messages
        for message in messages {
            let date = (message["date"] as! String).getDateString()
            if !contains(self.sections, date) {
                self.sections.append(date)
                self.data[date] = [ConversationMessage]()
            }
        }...

但它是在程序开始时声明的...

 var client: PubNub!

我修复了排序...就像在 swift 1.2

中一样
self.data[section]! = self.data[section]!.sort { Utils.compareDateTime([=10=].date, with: .date, order: .OrderedAscending) } 

无论如何,客户问题都留给了...

关于 'subscript' 的不明确使用,您必须将 messageInfo 强制转换为预期类型

if let messageInfo = message.data.message as? [String:AnyObject] {

真正需要类型注释的情况很少。