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!)
}
})