iPhone - NSData from local file's URL

前端 未结 5 1516
说谎
说谎 2021-01-30 19:39

I have a NSURL object which gives me the path of a local file (in documents folder). I want to populate an NSData object with the contents of this file

5条回答
  •  别跟我提以往
    2021-01-30 20:00

    For swift3 I found answer from following URL helpful

    ( I was getting following path , after capturing image using phonegap plugin

    file:///var/mobile/Containers/Data/Application/B64B06DE-7976-45CF-9BE2-661F0F309A06/tmp/abcded.jpg )

    https://stackoverflow.com/a/41043447/6383908

    if let videoURL = URL(string: urlString), let videodata = try? Data(contentsOf: videoURL) { //Add code of Alamofire here }

提交回复
热议问题