iPhone - NSData from local file's URL

前端 未结 5 1382
说谎
说谎 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:10

    Make sure your local URL starts with "file://" then you would just have to do this:

     NSData *fileData = [NSData dataWithContentsOfFile:fileURL.path];
    

提交回复
热议问题