Skip to content

Commit bf8a1fb

Browse files
committed
retrieve objects
1 parent e4b5b2e commit bf8a1fb

2 files changed

Lines changed: 28 additions & 10 deletions

File tree

TutorialBase/TutorialBase/AppDelegate.m

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,42 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
1717
{
1818
[Parse setApplicationId:@"JBwWcL56y8D1Z91dtExHWEIIe1TATErLalzIZ77J"
1919
clientKey:@"9UIvBdajqaIibxptHCPKTyUHk9ac1WETOx5LCo7a"];
20+
21+
// synchronous code
22+
2023
// PFObject *player = [PFObject objectWithClassName:@"Player"];
2124
// [player setObject:@"Lokesh" forKey:@"Name"];
2225
// [player setObject:[NSNumber numberWithInt:1230] forKey:@"Score"];
2326
// [player save];
2427

25-
PFObject *anotherPlayer = [PFObject objectWithClassName:@"Player"];
26-
[anotherPlayer setObject:@"Guddu" forKey:@"Name"];
27-
[anotherPlayer setObject:[NSNumber numberWithInt:840] forKey:@"Score"];
28-
[anotherPlayer saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
29-
30-
if (succeeded){
31-
NSLog(@"Object Uploaded!");
32-
}
33-
else {
28+
// asynchronous code
29+
30+
// PFObject *anotherPlayer = [PFObject objectWithClassName:@"Player"];
31+
// [anotherPlayer setObject:@"Guddu" forKey:@"Name"];
32+
// [anotherPlayer setObject:[NSNumber numberWithInt:840] forKey:@"Score"];
33+
// [anotherPlayer saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
34+
//
35+
// if (succeeded){
36+
// NSLog(@"Object Uploaded!");
37+
// }
38+
// else {
39+
// NSString *errorString = [[error userInfo] objectForKey:@"error"];
40+
// NSLog(@"Error: %@", errorString);
41+
// }
42+
//
43+
// }];
44+
45+
// retreive players
46+
47+
PFQuery *query = [PFQuery queryWithClassName:@"Player"];
48+
[query whereKey:@"Score" greaterThan:[NSNumber numberWithInt:500]];
49+
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
50+
if (!error) {
51+
NSLog(@"Successfully retrieved: %@", objects);
52+
} else {
3453
NSString *errorString = [[error userInfo] objectForKey:@"error"];
3554
NSLog(@"Error: %@", errorString);
3655
}
37-
3856
}];
3957

4058
return YES;

0 commit comments

Comments
 (0)