Created
February 22, 2012 08:13
-
-
Save mrsidique/1883377 to your computer and use it in GitHub Desktop.
set card location
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
| for (NSUInteger i = 1; i < myZapCards.count; i++) { | |
| [cardsToQuery addObject:[myZapCards objectAtIndex:i]]; | |
| } | |
| PFQuery *query = [PFQuery queryWithClassName:@"cardLocation"]; | |
| //[query whereKey:@"card" equalTo:[myZapCards objectAtIndex:zapPageControl.currentPage]]; | |
| [query whereKey:@"card" containedIn:cardsToQuery]; | |
| [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) { | |
| if (!error) { | |
| // The find succeeded. | |
| NSLog(@"Successfully retrieved %d record.", objects.count); | |
| if (objects.count > 0) { | |
| for (PFObject *card in objects) { | |
| //get the ID for the card object | |
| PFObject *objectID = [NSString stringWithFormat:@"%@",[card objectId]]; | |
| //set the location of the retrived object to the current location | |
| PFQuery *updateLocation = [PFQuery queryWithClassName:@"cardLocation"]; | |
| [updateLocation getObjectInBackgroundWithId:[NSString stringWithFormat:@"%@", objectID] block:^(PFObject *object, NSError *error) { | |
| [object setObject:point forKey:@"location"]; | |
| [object saveInBackground]; | |
| }]; | |
| } | |
| } | |
| else { | |
| for (NSUInteger i = 0; i < cardsToQuery.count; i++) { | |
| PFObject *currentLocation = [PFObject objectWithClassName:@"cardLocation"]; | |
| [currentLocation setObject:[cardsToQuery objectAtIndex:i] forKey:@"card"]; | |
| [currentLocation setObject:point forKey:@"location"]; | |
| [currentLocation saveInBackground]; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment