我有一个存储在文档目录中的音频文件,现在我需要获取该音频文件并进行一些加密/解密。 我想要这样:
let audiofile = get audio file from document directory // This is what i want
encrypt(audiofile)// I have AES technique, This is not my question.
答案 0 :(得分:4)
这很简单!!!!
就像下面的代码::
var paths: [AnyObject] = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)
let audiofilePath = paths[0].stringByAppendingString("/myaudio.mp3")
//Write name of your audio at **myaudio.mp3**
//now you can use anywhere audiofilePath as String like
let audiourl : NSURL = NSURL((fileURLWithPath: audiofilePath))
//or you can make asset like
let assets = AVAsset(URL: NSURL(fileURLWithPath: audiofilePath))
享受编码,如果有任何帮助,只需问我..