I am trying to follow the following guidance from Apple about local file storage. How do I set the "do not back" attribute on files created by my apps in MonoTouch?
Technical docs here, but I can't find this in MonoTouch:
https://developer.apple.com/library/ios/#qa/qa1719/_index.html
Use the "do not back up" attribute for specifying files that should
remain on device, even in low storage situations. Use this attribute
with data that can be recreated but needs to persist even in low
storage situations for proper functioning of your app or because
customers expect it to be available during offline use. This attribute
works on marked files regardless of what directory they are in,
including the Documents directory. These files will not be purged and
will not be included in the user's iCloud or iTunes backup. Because
these files do use on-device storage space, your app is responsible
for monitoring and purging these files periodically."
This is available since MonoTouch 5.2 (and iOS 5.0.1) inside the MonoTouch.Foundation.NSFileManager type, methods SetSkipBackupAttribute and GetSkipBackupAttribute.
Related
I want to sync data between iPhone and iPad. I am using core data and save the data in Documents of Document Container. Since Documents is backed up by both iTunes and iCloud. Since iCloud is deprecated in latest version of Xcode. Do I have to do anything else to sync data between these iOS devices?
Backups are not a sync mechanism. For one thing, backups are device specific. Data that gets backed up from someone's iPhone is not available to their iPad. There is no device-to-device data mixing through backups.
Putting the persistent store file in iCloud (via the iCloud file API) is not workable either. You can't just read/write the file in iCloud directly, you need to download the file first and later upload changes. Core Data isn't designed to work in that scenario. You might write code to do it, but the data would become corrupted almost immediately because Core Data isn't expecting you to mess with the persistent store like that.
If you want to sync data between devices, there are many options. Apple offers CloudKit, which is free and supported by Apple. Firebase is popular. Parse servers are still extremely common even though Parse itself is shutting down. Add to that Microsoft Azure and many, many others.
I am working on an IOS 5.0+ project that uses the latest RestKit to download, map and persist core data. I am looking for a definitive answer on Apple's iCloud storage guidelines with RestKit. Do I need to take any extra steps to make sure the data downloaded for use in the app is not automatically backed up to an iCloud account.Do I need to alter the default location for the directories used. Thanks in advance.
If your Core Data store is not saved in an ubiquity container (See: URLForUbiquityContainerIdentifier:) it will never be synced.
Also in the Using iCloud in Conjunction with Core Data section of the documentation they state:
Setting up your Core Data store to handle iCloud requires only a
little extra effort on your part. The steps you must follow depend on
whether you are using a single Core Data store as a central library
for your app or whether you are creating separate stores for
individual documents.
You have to do some explicit changes for synchronization. If you read the documents further, they mention some keys like NSPersistentStoreUbiquitousContentNameKey. If you search for this in the RestKit source, you will not find it - this is because RestKit does not sync with iCloud automatically (and they can not because iCloud is an app level synchronization framework).
Our app was just rejected for storing our database in the Documents folder. The seed file or app content in the database has got 3.3MB. We also store user created content in the database of course. The official statement is: 2.23 Apps must follow the iOS Data Storage Guidelines or they will be rejected
So now we are checking out on Technical Q&A QA1719 to prevent the database from being synced to iCloud.
I am storing a lot of images, books, audios etc of my app in
Documents Directory/Library/caches folder.
What happens to all the content if the user updates the version of the app from the app store or from iTunes. Will all of them get erased or will they be untouched during the app updating process?
They will be untouched during the upgrade process. I would like to note however that the Caches folder is meant to be used for data that is just cached rather than data you expect to always be available. The OS reserves the right to get rid of anything in the caches folder. If you're asking this question then I assume you want the data to be persistent so you should be aware that since iOS 5, Apple specifically state that data in the caches directory can be deleted at any time (apart from whilst your app is running).
They are supposed to remain untouched. There are a lot of existing examples for this behavior - try checking any photo sharing application or games that download levels in-game.
i have an iphone app that uses coredata to store its contents. users often ask me if i could provide a way to sync data between their mobile devices (ipod/iphone/ipad). as of now, i have no idea on how to achieve this.
i found zsync, but this seems to depend on a osx version of the app (which i dont have). i also read about upcoming iclouds sync features, and it seems to be what i need - however i think its not possible to sync coredata contents, but text-based contents only (e.g. xml storage files). is this true?
another way i was thinking of was to abuse the eventkit api to sync via a user-provided calendar. since my app is mainly managing events, which can optionally be stored in a user-calendar (in addition to coredata storage), syncing through a calendar would seem good to me. however i think syncing might break, e.g. when the user chooses not to syncronize the whole calendar but only like 3 months in the devices settings/account settings.
anyone got an idea of how my approach should be like? any tips?
Syncing device to device (if that is what you are trying to achieve) can be quite tricky. You could implement your own discovery and data-transfer protocol and work something out that way, but it could be quite a bit of work.
Syncing device to server to device is a bit more straightforward, assuming that you already have a server with some form of registration/login system. Then you just need a way of communicating your current database state up to the server, and then back down again from the server to other devices. Again there is a fair bit of work involved in doing this, but at least the logic of working out which devices sync with which other devices and how they transfer data from one to the other is all implicit in the workings of the server.
As for iCloud, the programmatic content that you sync through it needs to be derived from UIDocument, so it will not help you with generic Core Data entities.
If you're looking for an out-of-the-box solution that will sync all of your Core Data content from one device to another with no custom code, then there really isn't one. The closest you can reasonably get would be to ship the entire .sqlite file that your app uses from one device to another, overwriting the target devices .sqlite file. That works fine if your sync only needs to be unidirectional, but obviously is not appropriate for other use-cases. Perhaps you could use this model with iCloud, if you can get it to sync your app's entire .sqlite file as an atomic entity.
I have an app that will need to cache some images.
I have read some documentation about caching, and the logical thing to do is to cache my images within the Library/Caches directory within my app's sandbox.
I understand that the reason for storing caches images here are:
Library/Caches isn't backed up by iTunes
Library/Caches is cleared periodically by the OS
That second point is what I'm questioning...
Is this true?
Does the OS clear the caches directory automatically?
Will I need any of my own logic to detect if the cache is too big and to clear the oldest items?
I found this in the documentation:
Use this directory to write any application-specific support files that you want to persist between launches of the application. Your application is generally responsible for adding and removing these files. However, iTunes removes these files during a full restore of the device so you should be able to recreate them as needed. To access this directory, use the interfaces described in “Getting Paths to Application Directories” to get the path to the directory.
In iPhone OS 2.2 and later, the contents of this directory are not backed up by iTunes.
http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/FilesandNetworking/FilesandNetworking.html