Search code examples
iosxcodecameracckcopying

How to access DCIM in Xcode


My idea: syncing music without wifi or bluetooth. First I get the the files I want , then I compress them into a zip file. Then I want to rename the extension JPG, so the iPad can recognize the file. Then I copy it to my sd card, then use camera connection kit to connect it to my iPad.

I wanted my app to copy the entire jpg form dcim so that I can change the file extension back to zip,then extract it to retire my files.

But so far I have only found a way to copy the picture, not the entire file. I need the entire file, which I wish you guys can help me.

Thanks in advance,


Solution

  • You can use NSFileManager's copyItemAtPath method like so:

    NSError *error;
    [[NSFileManager defaultManager] copyItemAtPath:sourceFile toPath:destFile error:&error];
    

    Where sourceFile would be the complete path to your jpg file, and destFile would be the complete path to your zip file.