iPhone : opening files + bundle subdirectories

Hello.

I would like to know :

- If there's another way to put and open files on the iPhone instead of using iPhone resource bundles (for example, I would like to add files later in my application "directory") ? It seems there's no way to put or open a file directly on the filesystem of the phone.

- If it is necessary to use bundles :
* is it possible to add a bundle later for an application (containing extra data files for example) ? (How ?)
* is it possible to use subdirectories in bundles ? (Even if I have subdirectories in my XCode resources directory, all the files seem to be copied in the same directory on the iPhone).

Thank you for your answer.

Patrick

MacBook, Mac OS X (10.5.4)

Posted on Sep 28, 2008 10:24 AM

Reply
7 replies

Sep 29, 2008 12:59 AM in response to msv123

In fact, my application needs to access files stored in such a hierarchy :

Directory1
- SubDirectory1
-- File1.txt
-- File2.txt
- SubDirectory2
-- File1.txt
-- File2.txt
Directory2
- SubDirectory1
-- File1.txt
-- File2.txt
- SubDirectory2
-- File1.txt
-- File2.txt

The problem is that the C-based library I use requires the path of the root directory and uses files in the subdirectories, so I added all that hierarchy in my project resources in XCode and I gave the path of the bundle to that library, but it did't work because all the files seem to be copied at the root of the bundle directory (ignoring my subdirectories). Is there any solution to that problem ?

Patrick

Sep 29, 2008 9:23 AM in response to patrick.schevenels

{quote}How can I access to that document folder ?{quote}
Check out the NSFileManager class reference and the methods contentsOfDirectoryAtPath:error: and contentsAtPath:

{quote}Is it possible to copy files to that folder directly from the Mac with USB?{quote}
No, apps that you write cannot send or receive data through the plug at the bottom of the device.

{quote}Can that folder be accessed from another application in order to share files between several applications?{quote}
No, all apps are sandboxed, meaning they cannot share memory or files with other apps.

Sep 29, 2008 9:40 AM in response to patrick.schevenels

i am not really sure,
but i think i remember reading somewhere that apps can read other apps data (if they know where the data is)
they just cannot write except in their sandbox

i think someone was developing a copy paste framework that was making use of it, ie: when "pasting" the pasting app would get the "copied" data from the "copied" app data

once again i can t really be sure,
i know i did read it, but dont know if it actually works
just wanted to share this,
maybe someone elese more informed can chime in

Oct 2, 2008 4:49 AM in response to Nonnus

Hi,
I made use of this (reading from another apps data) and had my application nearly on the AppStore, when Apple prevented the reading in iPhone OS 2.0.2. I asked Apple why they changes this and they said that it was always intended to sandbox applications completely (no reading and writing of data from/to outside), but that in firmware < 2.0.2 the reading was accidentally possible. So I had to change my application completely...
Best regards,
Matthias

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

iPhone : opening files + bundle subdirectories

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.