Downloading a file from url and saving to resources on iPhone

后端 未结 4 1278
感动是毒
感动是毒 2020-12-13 16:23

Is it possible to download a file (i.e. an sqlite database file) from the Internet into your iPhone application programmatically for later use within the application?

<
4条回答
  •  孤城傲影
    2020-12-13 16:48

    What is fileData? How is it defined and initialized?

      fileData = [NSMutableData data];
    

    should be somewhere after:

    NSURLConnection *conn = [NSURLConnection connectionWithRequest:req delegate:self];
    

    You have to initialize fileData and retain it per memory management rules.

    Try it with my answer. It Works!

提交回复
热议问题