How can I retrieve files from an iPad development tool app? - ipad

I'm not sure how best to word the Title of this, so if someone can suggest a better one, please feel free to edit.
I'm writing an app for iPad that requires me to create some of the app data files with the iPad itself during development, i.e. a tool I am building with the iPad will be used by the developers themselves to create sample files that can be played by the app itself.
My question is, how can I best do this? I tried writing files to a local dir on my mac while the iPad was connected but I get a crash. Ideally if there is some way for me to generate an output file on my iPad and get it transferred to my Mac while my dev build is running, I'd do that.
Suggestions?

It looks like the trick it to use Apple's File Sharing to place files in a folder accessible through iTunes, explained here:
Standard Application Behaviors
The gist is to add a UIFileSharingEnabled plist key set to true and then query the Documents folder for your application like so:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];

Related

iOS: Is this the proper way to setup a database location under the application support folder?

I have a sql file that needs to be stored in my App. A user on this site recommend me to store it underneath the Application Support folder. This is the path directory that I am using with my fmDatabase library.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
NSString *applicationSupportDirectory = [paths firstObject];
self.dataBasePath = [applicationSupportDirectory stringByAppendingString:#"Email.sqlite"];
self.fmDataBase = [FMDatabase databaseWithPath:self.dataBasePath];
Everything seems to be working fine. However, I am a little nervous that I may be doing something wrong. I am using the Application Support directory because I don't want the OS or an update to interfere with the Database. I would use the document directory ,but my App supports file share so the user can mess it up.
(application_home)/Library path is a place where you can create custom subdirectories for files you want backed up but not exposed to the user.
create a directory such as (application_home)/Library/Database and save files there.
for mac os x with sqlite The convention is to store it in the Application Support folder .
i.e. in ~/Library/Application Support/YourAppNam*/database.db
I think the data will be saved on the Application Support Folder in Mac platform, for iOS, the default is xxx/Library.
I don't see any dangerous element on this, because you can save to different folder as long as you can load it from right path.

How private document directory can be set in iOS8 as storage provider application extension is making default Document directory Shared?

My iOS app is running all well & good till iOS7. But as soon as I run on iOS8 beta version it crashed.
When I tried to investigate I found that in iOS8 Storage provider changed the path for the default document Directory.
How can I set it to default Document directory to keep the applications private data Safe
How are you getting the path of the Documents directory? If you use the recommended API (like below) it should translate over to ios8 without any problems.
NSString *docsDir = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
Also, not clear what you mean by "keeping private data safe" -- any data you write to the Documents directory is not accessible by any other app.

How to embed custom resources and folders in iOS applications

I have an iOS application that embeds a native C binary bundled as a static library. This binary was initially designed to work on "regular" computers and relies on some specific folder layout, something like:
myapp
- images
- big
- thumbnails
- templates
- sounds
For the binary to work properly, I need to keep this layout as it is. I haven't done much iOS development and maybe this is a trivial question, but how can I replicate this folder layout within my iOS application (and how to get its absolute path within the application) ?
Every app has a sandbox with a set of folders that you could use. Would your app still function if they were in say the Documents or Library folder?
NSString *documentsDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *libraryDir = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0];
There is also /tmp and /caches, but probably these aren't what you're looking for. I believe both of the above survive updates/sync.

How to get files into library directory for iphone device testing

I have tested my app on the ios simulator and using the following code:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *dictdir = [documentsDirectory stringByAppendingPathComponent:#"dict.plist"];
NSLog(dict);
I found the path in which to save my file, dict.plist so that it can be used later by the app.
I am now testing on my device and the place where I am intending to store my .plist file is
var/mobile/Applications/......./Documents/freq.plist
First of all, I know that non-user data is meant to be saved in the library folder, so how do I change my code so that the path is leading to the ..../library/ directory?
And how do I actually put my file in this directory? Right now using the 'organizer', I managed to get the file into the app sandbox, but not in a particular folder.
The same code will get the correct path on the device and simulator, that's what it is meant for. However, if you want to copy it, you have to include it in your bundle, or download it from the internet. You can't just copy it with the finder. For copying from the bundle, use the the function – copyItemAtURL:toURL:error:. Downloading is a bit more complicated and is probably better suited for a separate question.
Just change NSDocumentDirectory to NSLibraryDirectory

After iOS 5 update, files in my document directory are gone? Is iOS changing the documents directory?

I have a little problem with my app when updating to iOS5.
In my documents directory I have a sqlite file and PDF documents.
The sqlite file contains the url's of the PDF documents.
When I start my app, I can see the list of documents, which is saved in the sqlite file.
But when I want to open a pdf, the document is not found.
So I think iOS changes the document directory addresses.
Is that possible?
I save the addresses of my pdf's like that:
NSArray *pathArr = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask,
YES);
NSString *filename = [NSString stringWithFormat:#"%#/%#/%#",[pathArr objectAtIndex:0],title,versionString];
It's difficult to answer your question without mor information. The fact that you are able to read the sqlite file which you say is in the Documents folder indicates that your program can at least find that file.
You can look and see what exactly is in the Documents folder by setting the
Application Supports iTunes file sharing
attribute in the Application's info.plist file. You can then view the Application's Documents folder and add/remove files in iTunes.
You can also look in the
~Library/Application Support/iPhone Simulator/<IOSVERSION>/Applications/<UUID>/Documents
directory if you are running the simulator.
You will at least know what the actual contents of the Documents directory are...

Resources