Created
February 23, 2012 05:34
-
-
Save mrsidique/1890685 to your computer and use it in GitHub Desktop.
Get users
This file contains hidden or 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
| PFQuery *getUsers = [PFQuery queryWithClassName:@"cardLocation"]; | |
| // Interested in locations near user. | |
| [getUsers whereKey:@"location" nearGeoPoint:point withinMiles:10]; | |
| [getUsers findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) { | |
| if (!error) { | |
| resultSet = [[NSMutableArray alloc]initWithCapacity:1]; | |
| NSLog(@"Successfully retrieved %d record.", objects.count); | |
| for (PFObject *card in objects) { | |
| NSTimeInterval timeSinceLastUpdate = [card.updatedAt timeIntervalSinceNow]; | |
| //only display users if they've checked in less than 30 minutes ago | |
| if (timeSinceLastUpdate > -1800) { | |
| [card objectForKey:@"card" inBackgroundWithBlock:^(id object, NSError *error) { | |
| if (!error) { | |
| PFObject *cards = object; | |
| [cards objectForKey:@"cardOwner" inBackgroundWithBlock:^(id object, NSError *error) { | |
| if (!error) { | |
| PFObject *cardOwner = object; | |
| [cardOwner objectForKey:@"username" inBackgroundWithBlock:^(id object, NSError *error) { | |
| if (!error) { | |
| PFObject *userID = object; | |
| NSString *currentUserNameString = [NSString stringWithFormat:@"%@", [currentUser objectForKey:@"username"]]; | |
| NSString *fetchedUserNameString = [NSString stringWithFormat:@"%@", userID]; | |
| if (cards != nil) { | |
| //only get cards if they are currently set to broadcasting | |
| [cards objectForKey:@"active" inBackgroundWithBlock:^ (id object, NSError *error) { | |
| if (!error) { | |
| NSString *activeStatus = [NSString stringWithFormat:@"%@", object]; | |
| if ([activeStatus isEqualToString:@"1"]) { | |
| [cards objectForKey:@"broadcasting" inBackgroundWithBlock:^(id object, NSError *error) { | |
| if (!error) { | |
| NSString *broadcastingStatus = [NSString stringWithFormat:@"%@", object]; | |
| if ([broadcastingStatus isEqualToString:@"1"]) { | |
| if (![currentUserNameString isEqualToString:fetchedUserNameString]) { | |
| [resultSet addObject:cards]; | |
| [self setContentsList:resultSet]; | |
| [resultTableView reloadData]; | |
| } | |
| } | |
| } | |
| }]; | |
| } | |
| } | |
| }]; | |
| } | |
| } | |
| }]; | |
| } | |
| }]; | |
| } | |
| }]; | |
| } | |
| } | |
| } | |
| else { | |
| } | |
| }]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment