I am trying to write a file to somwhere on the device so that a javascript file can locate it. Current I am writing to the documents of the device. I am getting the directory but using
But I have notice that to directory is different for iPod and iPad (i don't know about iPhone). I have tried writing to other folders along the directory path like
You can use the documents directory. You dont need to know the exact path i.e. the "/var/mobile...", just that you have the ability to write files there.
Why do you think you need to know the exact path, and moreover, why do you think this path needs to be the same on different devices?
And it wrote to the documents of the device just fine. But I am reading it from a javascript file. But when I used
Code:
NSLog(@"%@", documentsDirectory);
I noticed that it changed from the iPod to the iPad. So I think I need to either write the file using the same path or somehow pass documentDirectory into the javascript file.
And it wrote to the documents of the device just fine. But I am reading it from a javascript file. But when I used
Code:
NSLog(@"%@", documentsDirectory);
I noticed that it changed from the iPod to the iPad. So I think I need to either write the file using the same path or somehow pass documentDirectory into the javascript file.
There is no guarantee that the path to the documents directory will be the same between devices. In fact, it is likely to be different on every device. The system assigns a path to your app when it gets installed from the app store, and that path is quite likely to be different from device to device and user to user.
You should ask the system for the path to the documents directory and use that. Don't assume it will stay the same.
You will need a way to pass it to JavaScript of you need to use it in JavaScript.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
directory is a var located at the top of the javascript file. I believe it is a global var. But this code is not working. I think it is because I have not specified the javascript file but I am not sure how to do that.
directory is a var located at the top of the javascript file. I believe it is a global var. But this code is not working. I think it is because I have not specified the javascript file but I am not sure how to do that.
I have no idea. I know very little about JavaScript. Sorry.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.