I am getting error while uploading profile image on quickblox.
Error is
fatal error: unexpectedly found nil while unwrapping an Optional value
on this
let imageData: NSData = UIImageJPEGRepresentation(userImage, compression)!
You can find the full documentation here. Here are the reasons that this method might return nil.
This function may return nil if the image has no data or if the underlying CGImageRef contains data in an unsupported bitmap format.
It's also stated that the compression argument should be a CGFloat between 0.0 and 1.0. This value determines the compression of the image. 0.0 being the lowest quality (maximum compression). 1.0 being the highest quality (minimun compression).
If this doesn't fix your problem you might want to add in the context so we can see what mutates the userImage and compression variables