Pass data from 3 plist files using custom URL scheme - iphone

I have a Lite and Full apps. I need to pass the data from 3 plist files which are in Documents folder of the app (Lite), to the new (Full) app. I understand it can be done with custom URL scheme. Can someone explain the process of exporting/importing the data?
Can anyone confirm that this could be done?

Because of the sandbox environment on iOS, an application is only able to access its own Documents folder. This means your Full app cannot access files (in your case the .plist files) from the Lite's Documents folder.

Related

When to use assets in Flutter

What is the best way to use assets in Flutter , for example if i have a file for app configuration , should I store the file by getting the app directory using the path_provider plugin -without using assets- and store it ?, or should I add the file to my program folder -add the file to my assets- ?
the same question if I have a small Sqlite database.
and which of these methods is faster , and which is more secure ?
Assets are files that you add to your app during development. You can load them with rootBundle.load() or rootBundle.loadString() but you cannot modify or delete them.
In the app's directory you can store any files that your app downloads or generates from the internet while running. These files can then be opened, deleted, modified, etc. To access your app directory you need the package path_provider, which tells you the path to your app folder.
A sqlite database is normally stored in the app directory. An example package would be here sqflite.
For speed and security I can't make a difference. An app directory is designed so that only the app can access it. Assets are a part of the app, the application file can theoretically be unpacked by anyone. Therefore I would at least not store secret things in the assets.
Well, if by app configuration you mean the user's settings you can use Sqlite, SharedPreferences or Hive (Hive shows a benchmark that says that it is faster than SharedPreferences).
I believe that assets folder is used to store some common files for the app, like images, icons, fonts, etc. And I think that isn't recommended to store files with some kind of config file, mainly with critical info about the app configuration.

How to copy a file from Documents Directory to application bundle?

Hi in my app launch i will invoke a web-service call and i will download some zip files now i need to save those files permanently in my application bundle so that when i launch my app for the second time i will just look for update if there is no update i will just use my previously saved files, so i thought to make use of document directory and get the zip file then unzip it and save it in application bundle, here my problem is how to save a file from DocumentsDirectory to my Application Bundle?
and does my approach is right & efficient way or do i need to follow some other ways to achieve this? Any help is thankful in advance.
You can't write to your application's bundle - it is readonly, only the documents directory is readwrite.
You don't need to move the files, as the documents directory provides permanent storage.
The resources which are modified at runtime should be part of Documents directory. iPhone application creates a sandbox environment which is signed. If you try to modify any of the bundle resource or try to add/remove the resource, it will not allow. It works fine with simulator but not with device.
So you should store your response to the documents directory and not to the bundle.

Why copy a plist from the resources to document?

This is what is my understanding: the resources in the project folder are read only. So, almost all examples show copying a plist from the resources to the app's document folder. Why can we not simply find the app's document folder (after first run) and create the initial plist there (i.e. in the documents folder of the app so that subsequently we can modify the plist via code?
The answer is: Yes, you can create an initial plist there. But before you do this, consider using NSUserDefaults to save the settings.
Because there might already be data needed in a plist when the app is first installed; and that data has to come from somewhere. Why not from a plist?
I would also suggest using the Library folder rather than the Documents folder, just in case you do file sharing via iTunes at some stage. The Documents folder is available to the end user, whereas the Library folder is not.

How can I save pdf's to my app resources folder, and access them in run-time?

I have an app I'm designing that will allow for lots of PDF viewing. There are a lot of different languages available, and so if I were to include all of them in the app, it would be like 100+ mb in size which just won't fly.
So I'm thinking that I am going to put the pdf's on my server, and access them with a direct download link like this:
http://mysite.com/pdfs/thepdf.pdf
Which will return the exact pdf I want. So I'm wondering how I can go about accessing these resources as I download them on the fly?
I imagine I need to save the pdf's to the app resources folder? And then when a tableView row for the pdf is selected, I check if the pdf is in the resources folder (how do I do that?), and if not, pull it down off the server, and load it into my view?
I think I have an okay idea of what I need to do, just not very clear on the code to do it. Can anybody post the code for accessing the resources folder (if that's actually what I need to be doing), and maybe the code for how to check if something is in the resources folder?
Thanks!
Have you considered using a UIWebView to view the PDF instead of downloading and loading it yourself? UIWebView should take care of caching, so you won't have to worry about that.
Assuming that a UIWebView won't work, to download PDFs and see if they exist, you need to store it in the Documents folder. The resources folder cannot be altered after you submit your app to Apple, but the Documents folder in your app is completely fine. To access it, I would actually recommend ConciseKit, which can be found on GitHub. It gives you a helper method to access your app's document directory. The helper method is
[$ documentPath];
Then you can get the path for a file by doing
[[$ documentPath] stringByAppendingPathComponent:#"file.pdf"];
So that is how you get a path to a file, to check if it exists, you want to use NSFileManager.
[[NSFileManager defaultManager] fileExistsAtPath:#"path from above"];

Is it possible to limit iOS file sharing functionality to a subfolder in the documents directory?

My image editing app is saving some important data in the documents directory. In a tutorial I was reading this:
iTunes will then display anything you
save to the Documents directory in
your app to the user, when they go to
the “Apps” page in iTunes and scroll
to the bottom:
I have a subfolder called userImages and it would be clever to restrict file sharing only to that folder and not to everything in documents. Otherwise the user would accidently (or on purpose) mess around with files that the app depends on to work properly. This would be bad.
Is there a way to restrict it to a subdirectory in documents?
No, what you should do instead is store anything you do not want users seeing in the "Library" directory for the app. Check here for a list of places you can store data:
How can I get a writable path on the iPhone?