0

I am creating a swift 3 parse live query messaging application. When a picture is sent, if the subscription gets the new message then i get the following error

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryI getDataInBackgroundWithBlock:]: unrecognized selector sent to instance 0x60000106e9c0'

When I reload the page and the original query gets the picture it works fine. Here is my code

this is my original query that I subscribe to

var messagesQuery: PFQuery<Message> {
    return (Message.query()?
        .whereKey("roomName", equalTo: chatName)
        .order(byAscending: "createdAt")) as! PFQuery<Message>

Here is my subscription to that query

func subscribeToUpdates() {
    subscription = liveQueryClient
        .subscribe(messagesQuery)
        .handle(Event.created) { _, message in
            self.messages.append(message)
            DispatchQueue.main.async(execute: {
                self.collectionView?.reloadData()
            })
        }
}

Here is the code causing the crash to occur (again only when the message is recieved via live query subscription rather than traditional query)

(message.image)?.getDataInBackground(block: { (data:Data?, error:Error?) in
    if error == nil {
        cell.messageImageView.image = UIImage(data: data!)
    }
})
Abdullah Khan
  • 12,010
  • 6
  • 65
  • 78
user6520705
  • 705
  • 3
  • 11
  • 38
  • Put cell.messageImageView.image = UIImage(data: data!) code in main thread using DispatchQueue.main.async { ...your image code.. } – Gagan_iOS May 14 '17 at 08:02
  • @Gagan_iOS where exactly would i put it, right now it is inside my cell for item at indexpath function. – user6520705 May 14 '17 at 14:59

0 Answers0