12
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ALAssetsLibraryのALAssetからNSDataを作る

Last updated at Posted at 2014-11-04

何度も漂流してやっと辿り着いた。  
今となっては何故こんなに苦戦したのかはわからない。

ALAssetsLibrary().assetForURL(url,
    resultBlock: { (asset: ALAsset!) in
        // Convert from ALAsset to NSData
        var rep = asset.defaultRepresentation()
        var bufferSize = UInt(Int(rep.size()))
        var buffer = UnsafeMutablePointer<UInt8>(malloc(bufferSize))
        var buffered = rep.getBytes(buffer, fromOffset: 0, length: Int(rep.size()), error: nil)
        var data = NSData(bytesNoCopy: buffer, length: buffered, freeWhenDone: true)
    },
    failureBlock: { (error: NSError!) in
    }
)

٩(๑❛ᴗ❛๑)۶

12
12
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?