title: image from ALAsset in swift
body: <p>I have images that returned from the camera by the ALAssetsLibrary. Now, I want to display it in a <code>UIImageView</code>. I tried this code, but it shows some errors:</p>
  
  <pre><code>var assets : ALAsset = photoArray.objectAtIndex(indexPath.row) as ALAsset
  
  cell.cameraOutlet.image = UIImage(CGImage: assets.thumbnail()) as UIImage // Showing error - Missing argument for parameter 'inBundle' in call 
  </code></pre>
  
  <p>after that, I tried this code:</p>
  
  <pre><code>var assets : ALAsset = (photoArray.objectAtIndex(indexPath.row) as ALAsset)
   var imageRef : CGImageRef = assets.thumbnail() as CGImageRef // showing error - Unmanaged&lt;CGImage&gt;, is not convertible to CGImageRef
   cell.cameraOutlet.image = UIImage(CGImage: assets.thumbnail()) as UIImage // Showing error - Missing argument for parameter 'inBundle' in call 
  </code></pre>
  
  <p>I want to display the image, how can I do this? </p>
  
  <pre><code>dispatch_async(dispatch_get_main_queue(), {
  self.photoLibrary.enumerateGroupsWithTypes(ALAssetsGroupType(ALAssetsGroupAlbum),
      usingBlock: {
  
          (group: ALAssetsGroup!, stop: UnsafePointer&lt;ObjCBool&gt;) -&gt; Void in
          if group != nil {
              group.enumerateAssetsUsingBlock({
                  (asset: ALAsset!, index: Int, stop: UnsafePointer&lt;ObjCBool&gt;) -&gt; Void in
  
                  if asset != nil
                  {
                      if asset.valueForProperty(ALAssetPropertyType).isEqualToString(ALAssetTypePhoto)
                      {
                          self.photoArray.addObject(asset)
                      }
                  }
                  })
          }
          self.collectionView.reloadData()
      },
      failureBlock: {
          (myerror: NSError!) -&gt; Void in
          println("error occurred: \(myerror.localizedDescription)")
      })
      })
  
  override func numberOfSectionsInCollectionView(collectionView: UICollectionView!) -&gt; Int {
          //#warning Incomplete method implementation -- Return the number of sections
          return photoArray.count
      }
  
  
      override func collectionView(collectionView: UICollectionView!, numberOfItemsInSection section: Int) -&gt; Int {
          //#warning Incomplete method implementation -- Return the number of items in the section
          return 1
      }
  
      override func collectionView(collectionView: UICollectionView!, cellForItemAtIndexPath indexPath: NSIndexPath!) -&gt; UICollectionViewCell! {
      let cell  : CameraCollectionViewCell = collectionView.dequeueReusableCellWithReuseIdentifier("Camera", forIndexPath: indexPath) as CameraCollectionViewCell
  
          var asset : ALAsset = photoArray.objectAtIndex(indexPath.row) as ALAsset
          cell.cameraOutlet.image = UIImage(CGImage: asset.thumbnail().takeUnretainedValue()) as UIImage
          return cell
      }
  </code></pre>
  
  <p>The output shows only one image for a 100 time I think. Whats the problem with this code?</p>