I have an optional image in Cloudkit (a verified DB and the image is where I added it in my testing). I created a class that initializes the record fields in the variables that I use in my table view. I also have a custom cell. But the image will not display in my custom tableview cell. I do not know if there is a problem with an additional image in the table image, or if there is a problem with my code / settings in cloudkit.
Any help is greatly appreciated since I was stuck for a week and there is nothing to know about it on the Internet.
Here is my class code:
var feedResults = [UserPosts]()
class UserPosts {
var record: CKRecord
var description: String
var username: String
var postPic: UIImage?
init(record: CKRecord) {
self.record = record
self.description = record.objectForKey("description") as String
self.username = record.objectForKey("username") as String
if var pic = record.objectForKey("postPic") as CKAsset! {
self.postPic = UIImage(contentsOfFile: pic.fileURL.path!)
}
}
}
Here is my table code:
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as TableViewCell
let record = feedResults[indexPath.row]
cell.postDescription.text = record.description
cell.userName.text = record.username
if record.postPic != nil {
cell.postPic.image = record.postPic!
}
return cell
}
CKAset UIImage. - , , Apple CloudKitAtlas. Obj-C, , - CloudKitAtlas
, NSData (contentOFFile:) UIImage (:), : SO CKAsset