Last active
February 8, 2017 03:22
-
-
Save yat1ma30/636cd05f07cf7e930021 to your computer and use it in GitHub Desktop.
ALAssetsLibraryのALAssetからNSDataを作る ref: http://qiita.com/ottati/items/20e93fb18d90d2d585fe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Will swift3 how to deal with it?