Database Reference
In-Depth Information
That's all we need to do to add our app to Settings and give the user a setting that they can change.
You can build and run your app to see it in action. But we aren't using it just yet. We will get to that
soon.
A Few More Constants
Let's set the table now by adding a few more constants to our constants class files. In the .h file add
the following declarations.
NSString * const CTiCloudOn;
NSString * const CTiCloudWasOn;
NSString * const CTPromptedForiCloud;
Now, lets assign these a value in the .m file.
NSString * const CTiCloudOn = @"ICLOUD_ON";
NSString * const CTiCloudWasOn = @"ICLOUD_WAS_ON";
NSString * const CTPromptedForiCloud = @"PROMPTED_FOR_ICLOUD";
Many Different States
When integrating iCloud we need to determine the possible states in which our app could be used.
Is the user on iCloud or are they not on iCloud? Have they been on iCloud?
There are four states that we are going to concern ourselves with. They are
iCloud has been turned on for the first time.
iCloud has been switched off.
iCloud isn't available, but it was previously on.
iCloud isn't on, but it is available.
To help us determine the state, we add a few helper methods inside of our
FriendsCollectionViewController.m file.
#pragma mark - Helpers
-(BOOL)iCloudOn {
return [[NSUserDefaults standardUserDefaults] boolForKey:CTiCloudOn];
}
-(void)setiCloudOn:(BOOL)on {
[[NSUserDefaults standardUserDefaults] setBool:on forKey:CTiCloudOn];
[[NSUserDefaults standardUserDefaults] synchronize];
}
-(BOOL)iCloudWasOn {
return [[NSUserDefaults standardUserDefaults] boolForKey:CTiCloudWasOn];
}
 
Search WWH ::




Custom Search