title: CKAsset won't show in tableview image
body: <p>I have an optional image in the cloudkit DB(checked DB and the image is there in cases where I added it in my testing). I have created a class that initializes the record fields into variables I use in my tableview. I have a custom cell as well. But the image won't display in my custom tableview cell. I don't know if having an optional image in a tableview image is causing a problem or if there's an issue with my code/settings in cloudkit. </p>
  
  <p>Any help is greatly appreciated, as I've been stuck for over a week and there's little to nothing online about this. </p>
  
  <p>Here's my class code:</p>
  
  <pre><code>var feedResults = [UserPosts]()
  
  class UserPosts {
  
  var record: CKRecord
  var description: String
  var username: String
  //var image: CKAsset? // tried also initializing the CKAsset separately
  var postPic: UIImage?
  
  
  init(record: CKRecord) {
  
      self.record = record
      self.description = record.objectForKey("description") as String
      self.username = record.objectForKey("username") as String
     // self.image = record.objectForKey("postPic") as? CKAsset
  
  
      if var pic = record.objectForKey("postPic") as CKAsset! {
  
             self.postPic = UIImage(contentsOfFile: pic.fileURL.path!)
  
              // below is the other way I've seen it done.
                 // var url = pic.fileURL!
                 // var imageData = NSData(contentsOfFile: url.path!)
                // self.postPic = UIImage(data: imageData!)
  
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Here's my tableview code:</p>
  
  <pre><code>    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; 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
  }
  </code></pre>
  
  <p>Also I've seen a couple ways of pulling a CKAsset into a UIImage. The first way, is how I saw Apple do it in their CloudKitAtlas project. Although I'm not well versed in Obj-C, I think I followed it correctly - <a href="https://developer.apple.com/library/ios/samplecode/CloudAtlas/Listings/CloudKitAtlas_AAPLCKAssetViewController_m.html#//apple_ref/doc/uid/TP40014599-CloudKitAtlas_AAPLCKAssetViewController_m-DontLinkElementID_6" rel="nofollow noreferrer">CloudKitAtlas Example</a></p>
  
  <p>I've also seen it done using NSData(contentOFFile:) and UIImage(data:), as shown in this post here: <a href="https://stackoverflow.com/questions/28206955/fetch-record-assets-in-cloudkit-using-swift">SO CKAsset Example</a></p>