In the first PFQuery (passengers) I get several meanings, among which are sometimes far apart special identifier, which must transmit data in the second PFQuery (trip). Data from the first identifier must be passed in getObjectInBackgroundWithId: XXXX (class trip). How can I do this?
- (void)viewDidLoad {
UISwipeGestureRecognizer *gestureRight;
gestureRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeRight:)];
[[self view] addGestureRecognizer:gestureRight];
PFQuery *passenger = [PFQuery queryWithClassName:@"ClubWorld"];
[passenger getObjectInBackgroundWithId:@"zB96iIkoqo" block:^(PFObject *ClubWorld, NSError *error) {
// Do somethi ng with the returned PFObject in the gameScore variable.
NSLog(@"%@", ClubWorld);
self.firstName.text = ClubWorld[@"firstName"];
self.lastName.text = ClubWorld[@"lastName"];
self.Mileage.text = ClubWorld[@"clubMiles"];
self.withBAFrom.text = ClubWorld[@"withBAFrom"];
self.withFCFrom.text = ClubWorld[@"withFCFrom"];
self.fundsSpent.text = ClubWorld[@"fundsSpent"];
self.lastTrip.text = ClubWorld[@"lastTrip"];
self.previoustripObjectID = ClubWorld[@"lastTrip"];
}];
PFQuery *trip = [PFQuery queryWithClassName:@"Trips"];
[trip getObjectInBackgroundWithId:self.previoustripObjectID block:^(PFObject *TripInformation, NSError *error) {
// Do something with the returned PFObject in the gameScore variable.
NSLog(@"%@", TripInformation);
self.fromCountry.text = TripInformation[@"fromCountry"];
self.toCountry.text = TripInformation[@"toCountry"];
self.departureAirport.text = TripInformation[@"departureAirport"];
self.arrivalAirport.text = TripInformation[@"arrivalAirport"];
self.earnedMiles.text = TripInformation[@"earnedMiles"];
self.flightClass.text = TripInformation[@"flightClass"];
self.departureTime.text = TripInformation[@"departureTime"];
self.arrivalTime.text = TripInformation[@"arrivalTime"];
self.flightCost.text = TripInformation[@"flightCost"];
}];
[super viewDidLoad];
}
In PassengerViewController.h need write this code:
@property (strong, nonatomic) NSString *previoustripObjectID;
In PassengerViewController.m need write this code:
-
(void)viewDidLoad {
UISwipeGestureRecognizer *gestureRight;
gestureRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeRight:)];
[[self view] addGestureRecognizer:gestureRight];
[self passengerRequest];
[self previousTrip];
[super viewDidLoad];
}
- (void)passengerRequest {
PFQuery *passenger = [PFQuery queryWithClassName:@"ClubWorld"];
[passenger getObjectInBackgroundWithId:@"jnDrQthmQX" block:^(PFObject *ClubWorld, NSError *error) {
NSLog(@"%@", ClubWorld);
self.profilePhoto = ClubWorld[@"passengerPhoto"];
self.firstName.text = ClubWorld[@"firstName"];
self.lastName.text = ClubWorld[@"lastName"];
self.Mileage.text = ClubWorld[@"clubMiles"];
self.withBAFrom.text = ClubWorld[@"withBAFrom"];
self.withFCFrom.text = ClubWorld[@"withFCFrom"];
self.fundsSpent.text = ClubWorld[@"fundsSpent"];
self.previoustripObjectID = ClubWorld[@"lastTrip"];
}];
}
- (void)previousTrip {
PFQuery *trip = [PFQuery queryWithClassName:@"Trips"];
[trip getObjectInBackgroundWithId:self.previoustripObjectID block:^(PFObject *TripInformation, NSError *error) {
NSLog(@"%@", TripInformation);
self.fromCountry.text = TripInformation[@"fromCountry"];
self.toCountry.text = TripInformation[@"toCountry"];
self.departureAirport.text = TripInformation[@"departureAirport"];
self.arrivalAirport.text = TripInformation[@"arrivalAirport"];
self.earnedMiles.text = TripInformation[@"earnedMiles"];
self.flightClass.text = TripInformation[@"flightClass"];
self.departureTime.text = TripInformation[@"departureTime"];
self.arrivalTime.text = TripInformation[@"arrivalTime"];
self.flightCost.text = TripInformation[@"flightCost"];
}];
}