Last active
December 14, 2015 07:19
-
-
Save ddrscott/5049627 to your computer and use it in GitHub Desktop.
Using Parse.com API, how to save and retrieve an object in offline mode?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- testOffline { | |
// Important! do all methods without Network | |
PFObject *todo1 = [PFObject objectWithClassName:@"Todo"]; | |
[todo1 setObject:@"Learn Parse API" forKey:@"text"]; | |
[todo1 saveEventually]; | |
PFObject *todo2 = [PFObject objectWithClassName:@"Todo"]; | |
[todo2 setObject:@"Implement iOS" forKey:@"text"]; | |
[todo2 saveEventually]; | |
PFObject *todo3 = [PFObject objectWithClassName:@"Todo"]; | |
[todo3 setObject:@"Implement Android" forKey:@"text"]; | |
[todo3 saveEventually]; | |
} | |
- testOfflineSometimeLaterButStillOffline { | |
// still offline | |
PFQuery *query = [PFQuery queryWithClassName:@"Todo"]; | |
query.cachePolicy = kPFCachePolicyCacheElseNetwork; | |
NSArray * results = [query findObjects]; | |
NSLog(@"Why are results empty? results => %@", results); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment