How can I store image to iCloud from my iphone application? - iphone

I got a project like MyPhoto Pro app in iPhone App Store (website).
Please, can any one help or guide me what are the technologies and frameworks i should use for developing?
But my primary things is that image should stored in iCloud.

For iCloud file storage see Designing for Documents in iCloud in docs.
Then check NSFileManager class, section Managing ICloud-Based Items.
-ubiquityIdentityToken – detect iCloud availability
-URLForUbiquityContainerIdentifier: – obtain URL for iCloud directory (container)
-setUbiquitous:itemAtURL:destinationURL:error: – move any local file to iCloud (or vice versa); one URL must be local and one must point into one of the iCloud containers
-startDownloadingUbiquitousItemAtURL:error: – download the file content
-evictUbiquitousItemAtURL:error: – delete iCloud file.
Also check NSMetadataQuery and NSMetadataItem classes used to discover new iCloud files. iCloud will automatically give you only metadata of the file, but content must be downloaded explicitely (see the methods above)

Related

iOS iCloud document change notification

Can you, in Swift get a change notification when a document in the apps's iCloud Drive container changes?
For example I am testing a simple concept where I am storing all app data as a json string in the app's iCloud Drive container and I am loading it when the app launches. I can retrieve and save the json string on demand on multiple devices, but I am wondering if there is a way to get a change notification sent to an app when the file is changed on another device.
If so, some direction would be appreciated.
If you are using UIDocument, you can register for UIDocumentStateChangedNotification (for a particular document), otherwise if you are looking for changes in the App's iCloud container you need to use NSMetaDataQuery which is described in Discovering an App's Documents in Document-Based App Programming Guide for iOS

RestKit and iCloud directory backup policies

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.

Icloud Sync between 2 app having different app identifier

I have an app which has different app identifier for iphone and ipad and i want to sync both of them using icloud, is it posible to use different app identifer for same container in icloud.
Yes, it is possible to sync data between different apps using iCloud (different apps always have different app IDs, don't they?). Use the entitlements of your apps to specify to which containers they should have access. Then use a common container to store and sync your files.
Update on 10/30/2013 on request of Dinesh Kaushik:
Open your project in Xcode and select the project in the ProjectNavigator
Go to the "Capabilities" Tap (Xcode 5) of the project and find the iCloud section (should be right on the top)
Here you can specify all Ubiquity Container the app should have access to.
To share data between apps they need to share a common Ubiquity Container. Thus add at least one Ubiquity Container that is used by
all participating apps. The easiest way to just one Ubiquity
Container (of course the same in each app)
When "connecting" to iCloud you use the following code to get the Ubiquity URL:
NSURL *cloudURL = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil];
Using nil as identifier will return the URL of the default Ubiquity Container. Use a concrete ID to get the URL of another Ubiquity Container.
The Ubiquity Container is basically just a folder on your device. The iCloud Service will observe this folder and transfer all changes to the same folder on other devices.
From my experience there is one golden rule about iCloud:
DONT USE IT!
I am serious. iCloud is unstable and unreliable. Your app might crash from time to time and you will never find out the concrete source of the problem. Users will ask why syncing does not work from time to time and blame you and your app for the poor performance.
iCloud might be OK for simple KeyValueStore but anything else is a mess. Do not wast your time. Use another Cloud service like Dropbox instead.

MonoTouch: How to set the "do not back up" attribute

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.

Is Library/Caches cleared automatically by the iPhoneOS?

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