I have a function which requires return parameter:
override func collectionView(collectionView: JSQMessagesCollectionView!,
avatarImageDataForItemAtIndexPath indexPath: NSIndexPath!) -> JSQMessageAvatarImageDataSource! { ... }
So it requires JSQMessageAvatarImageDataSource
this. When I try to:
self.downloadAvatar(OneChat.sharedInstance.fetchVCardOfOtherUserBy((OneChat.sharedInstance.xmppStream?.myJID)!).avatarURL, completion: { (image) in
return JSQMessagesAvatarImageFactory.avatarImageWithImage(image, diameter: 30)
})
where:
private func downloadAvatar(URL: String, completion: (image: UIImage) -> Void) {
let manager = SDWebImageManager.sharedManager()
manager.downloadWithURL(NSURL(string: URL), options: .RefreshCached, progress: nil, completed: { (image: UIImage!, error: NSError!, imageCache: SDImageCacheType!, finished: Bool) in
if (image != nil) {
completion(image: image)
}
})
}
it does not see my return inside of completionHandler and gives me this error:
Missing return in a function expected to return 'JSQMessageAvatarImageDataSource!'
How can I fix that?