I am having a problem when querying images in my app. I have a column in the user table that contains the users' images. When I try to get the data from that column, it shows weird errors. It seems to be related to Parse, and I have seen that others are having similar problems, but I don't see a good solution.
The UI freezes up, and it doesn't seem to be able to get the image data from the file. I get errors like the following over and over again:
2017-02-20 21:48:43.070389 BonApp[20160:4668014] [Error]: unsupported URL (Code: 100, Version: 1.14.2)
2017-02-20 21:48:43.072297 BonApp[20160:4668014] [Error]: Network connection failed. Making attempt 1 after sleeping for 1.224872 seconds.
Please help!
PS-- I have tried changing the query URL from 'https' to 'http' but that causes other problems-- the data seems to be mixed up as if the queries are pulled from the wrong row.
static func getUserImage(_ userId:String) -> UIImageView? {
let query = PFQuery(className:"UserImage")
query.whereKey("userId", equalTo:userId)
var userPhotoView:UIImageView?
var objects:[PFObject]?
do {
objects = try query.findObjects()
} catch {
print(error)
}
if let objects = objects {
for object in objects {
let tempPhoto = object["image"] as! PFFile
var imageData:Data?
do {
imageData = try tempPhoto.getData()
} catch {
print(error)
}
if let imageData = imageData {
let userPhoto = UIImage(data:imageData)!
userPhotoView = UIImageView(frame: CGRect(origin: CGPoint(x: 0, y: 0), size: CGSize(width: 42, height: 42)))
userPhotoView!.image = userPhoto
}
}
}
return userPhotoView
}