Home Ask Login Register

Developers Planet

Your answer is one click away!

Alexandre Ascone February 2016

Error using JSQMessagesViewController

Trying to make an Chat app on Iphone and I've a problem when integrating JSQMessagesViewController.

here is the full page code of my "ConversationViewController"

import UIKit
import JSQMessagesViewController

class ConversationViewController :  JSQMessagesViewController {
    var myIndexPath:Int!
    let outgoingBubble = JSQMessagesBubbleImageFactory().outgoingMessagesBubbleImageWithColor(UIColor(red: 63/255, green: 173/255, blue: 169/255, alpha: 1.0))
    let incomingBubble = JSQMessagesBubbleImageFactory().incomingMessagesBubbleImageWithColor(UIColor(red: 230/255, green: 231/255, blue: 236/255, alpha: 1.0))
    var messages = [JSQMessage]()
    override func viewDidLoad() {
        // Do any additional setup after loading the view, typically from a nib.
        self.navigationItem.title = "\(myIndexPath)"
    override func didReceiveMemoryWarning() {
        // Dispose of any resources that can be recreated.
    func reloadMessagesView() {

//MARK - Setup
extension ConversationViewController {
    func addDemoMessages() {
        for i in 1...3 {
            let sender = (i%2 == 0) ? "Server" : self.senderId
            let messageContent = "Et eodem impetu Domitianum praecipitem per scalas itidem funibus constrinxerunt. \(i)"
            let message = JSQMessage(senderId: sender, displayName: sender, text: messageContent)
            self.messages += [message]


    func setup() {
        self.senderId = UIDevice.currentDevice().identifierForVendor?.UUIDString
        self.senderDisplayName = UIDevice.currentDevice().identifierForVendor?.UUIDString

//MARK - Data Source
extension ConversationViewController {

    override func collectionView(collectionView: UICollectionView, numberOfItem        


Daniel Leonard February 2016

It is required so you just need to override it and pass back nil.

override func collectionView(collectionView: JSQMessagesCollectionView!, avatarImageDataForItemAtIndexPath indexPath: NSIndexPath!) -> JSQMessageAvatarImageDataSource? { return nil }

You can just add it to that same file. Then you should be good.

Post Status

Asked in February 2016
Viewed 3,361 times
Voted 13
Answered 1 times


Leave an answer

Quote of the day: live life