Edited at

ALAssetsLibraryのALAssetからNSDataを作る

More than 3 years have passed since last update.

何度も漂流してやっと辿り着いた。  

今となっては何故こんなに苦戦したのかはわからない。

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
}
)

٩(๑❛ᴗ❛๑)۶