输入' ConversationViewController'不符合协议' ATLConversationViewControllerDataSource'

时间:2016-07-06 05:24:45

标签: ios xcode swift

我正在使用Layer并尝试将Atlas集成到我的项目中。在这行代码中,

class ConversationViewController: ATLConversationViewController, ATLConversationViewControllerDelegate, ATLConversationViewControllerDataSource

Xcode抛出错误,"键入' ConversationViewController'不符合协议' ATLConversationViewControllerDataSource'。

我正在研究Swift 2.2。我的整个代码是

class ConversationViewController: ATLConversationViewController, ATLConversationViewControllerDelegate, ATLConversationViewControllerDataSource {

override func viewDidLoad() {
    super.viewDidLoad()
    self.dataSource = self
    self.delegate = self
}

// MARK - ATLConversationViewControllerDelegate methods
func conversationViewController(viewController: ATLConversationViewController, didSendMessage message: LYRMessage) {
    print("Message sent!")
}

// MARK - ATLConversationViewControllerDataSource methods
func conversationViewController(conversationViewController: ATLConversationViewController, participantForIdentifier participantIdentifier: String) -> ATLParticipant? {
    if (participantIdentifier.isEmpty == false) {
        let user = ConversationParticipant()
        user.participantIdentifier = participantIdentifier
        user.firstName = participantIdentifier
        return user
    }
    return nil
}

func conversationViewController(conversationViewController: ATLConversationViewController, participantForIdentifier participantIdentifier: String) -> ATLParticipant? {
    if (participantIdentifier.isEmpty == false) {
        let user = ConversationParticipant()
        user.participantIdentifier = participantIdentifier
        user.firstName = participantIdentifier
        return user
    }
    return nil
}

func conversationViewController(conversationViewController: ATLConversationViewController, attributedStringForDisplayOfDate date: NSDate) -> NSAttributedString {
    let attributes = [NSFontAttributeName : UIFont.systemFontOfSize(14), NSForegroundColorAttributeName: UIColor.grayColor()]
    let dateFormatter = NSDateFormatter()
    dateFormatter.dateFormat = "dd-MM-yyyy"

    return NSAttributedString.init(string: dateFormatter.stringFromDate(date), attributes: attributes)
}

func conversationViewController(conversationViewController: ATLConversationViewController, attributedStringForDisplayOfRecipientStatus recipientStatus: [NSObject:AnyObject]) -> NSAttributedString {
    if (recipientStatus.count == 0) {
        return NSAttributedString()
    }
    let mergedStatuses: NSMutableAttributedString = NSMutableAttributedString()

    let recipientStatusDict = recipientStatus as NSDictionary
    let allKeys = recipientStatusDict.allKeys as NSArray
    allKeys.enumerateObjectsUsingBlock { participant, _, _ in
        let participantAsString = participant as! String
        if (participantAsString == self.layerClient.authenticatedUser?.userID) {
            return
        }

        let checkmark: String = "✔︎"
        var textColor: UIColor = UIColor.lightGrayColor()
        let status: LYRRecipientStatus! = LYRRecipientStatus(rawValue: Int(recipientStatusDict[participantAsString]!.unsignedIntegerValue))
        switch status! {
        case .Sent:
            textColor = UIColor.lightGrayColor()
        case .Delivered:
            textColor = UIColor.orangeColor()
        case .Read:
            textColor = UIColor.greenColor()
        default:
            textColor = UIColor.lightGrayColor()
        }
        let statusString: NSAttributedString = NSAttributedString(string: checkmark, attributes: [NSForegroundColorAttributeName: textColor])
        mergedStatuses.appendAttributedString(statusString)
    }
    return mergedStatuses;
}

// MARK - ATLParticipantTableViewController Delegate Methods

func participantTableViewController(participantTableViewController: ATLParticipantTableViewController, didSelectParticipant participant: ATLParticipant) {
    print("participant: \(participant)")
    self.addressBarController.selectParticipant(participant)
    print("selectedParticipants: \(self.addressBarController.selectedParticipants)")
    self.navigationController!.dismissViewControllerAnimated(true, completion: nil)
}

我已经实现了所有必需的方法。我仍然得到同样的错误。任何帮助将不胜感激..

0 个答案:

没有答案