-
Notifications
You must be signed in to change notification settings - Fork 102
Open
Description
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.
}
}
Metadata
Metadata
Assignees
Labels
No labels