Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dataSource set to nil #38

Open
shuchitgandhi opened this issue Jul 10, 2015 · 0 comments
Open

dataSource set to nil #38

shuchitgandhi opened this issue Jul 10, 2015 · 0 comments

Comments

@shuchitgandhi
Copy link

I am unable to set values to SOMessage Object (comment for my project) from my View Controller file. It gets set to nil. Here is the source code -->

//
// Message.swift
//

import UIKit

class Message: SOMessage {

// @synthesize attributes,text,date,fromMe,media,thumbnail,type;

override init() {
    super.init()
    self.date = NSDate()
}  

}

//
// CommentsVC.swift
//

import UIKit

class CommentsVC: SOMessagingViewController {

var dataSource: NSMutableArray!

override func viewDidLoad() {
    super.viewDidLoad()

    self.loadMessages()
}

func loadMessages(){

    var comment: Message = Message()
    comment.text = "HI ! This is Sparta !!!"
    comment.fromMe = false
    comment.type = SOMessageTypeText
    comment.date = NSDate()
    dataSource.addObject(comment)

}

override func intervalForMessagesGrouping() -> NSTimeInterval {
    return NSTimeInterval(0)
}

override func messages() -> NSMutableArray {
    return dataSource
}

override func configureMessageCell(cell: SOMessageCell!, forMessageAtIndex index: Int) {

    var message: Message = self.dataSource[index] as! Message;

    println(message.fromMe)

    if (message.fromMe != false) {
        cell.contentInsets = UIEdgeInsetsMake(0, 3.0, 0, 0) //Move content for 3 pt. to right
        cell.textView.textColor = UIColor.blackColor()
    } else {
        cell.contentInsets = UIEdgeInsetsMake(0, 0, 0, 3.0); //Move content for 3 pt. to left
        cell.textView.textColor = UIColor.whiteColor();
    }
}

override func messageInputView(inputView: SOMessageInputView!, didSendMessage message: String!) {

    var msg: Message = Message()
    msg.text = message
    msg.fromMe = true

    self.sendMessage(msg)
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant