Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Save file directly into Documents Directory (in XCode)

ForswornForsworn Posts: 504New Users
edited April 2009 in iOS SDK Development
Is this possible?
At the moment I'm holding a default file in the Resources group and then copy it programmatically to the Documents directory.
But now I've got 2 files.
No problem, as I could use the first one as backup.

But I'd like to know, if it's possible to save a file directly into the documents directory.

Kind regards,
Fabian
Post edited by Forsworn on
·

Replies

  • lbendlinlbendlin Posts: 429Registered Users
    edited February 2009
    no, that is not possible. the copy has to happen on the device.
    ·
  • RickMaddyRickMaddy Posts: 2,122New Users
    edited February 2009
    Think of it this way. The Documents directory is not part of your app that you send to Apple. So it's not part of the app downloaded by the user. It's not until runtime on the device (or simulator) that the Documents, tmp, and Library directories are created as siblings to your app. So it's not until runtime that you can put something in the Documents directory.
    ·
  • ForswornForsworn Posts: 504New Users
    edited February 2009
    That sounds logical...
    Just thought there might be a path info or something.

    But having a valid backup is always good. When something goes wrong I can just reset the file.

    Thanks for your replies!

    Regards

    Edit:
    I know I can delete the file... But I prefer a backup.
    ·
  • JohnMabassaJohnMabassa Posts: 138Registered Users
    edited April 2009
    RickMaddy wrote: »
    Think of it this way. The Documents directory is not part of your app that you send to Apple. So it's not part of the app downloaded by the user. It's not until runtime on the device (or simulator) that the Documents, tmp, and Library directories are created as siblings to your app. So it's not until runtime that you can put something in the Documents directory.
    Uhh!! Do you mean that I cannot save something to a file and then save that file to application's document directory??
    writeToFile:filePath ??

    -John
    ·
  • smithdale87smithdale87 Posts: 4,447iPhone Dev SDK Supporter @ @ @ @ @
    edited April 2009
    Uhh!! Do you mean that I cannot save something to a file and then save that file to application's document directory??
    writeToFile:filePath ??

    -John

    No, what they are saying is you cannot manually drag & drop files into your apps document directory. It can only be done at runtime, e.g. by using writeToFile as you suggested.
    ·
Sign In or Register to comment.