PFQuery 没有得到标识符

PFQuery not getting identificator

在第一个PFQuery(passengers)中我得到了几个意思,其中有时是相隔很远的特殊标识符,在第二个PFQuery(trip)中必须传输数据。来自第一个标识符的数据必须在 getObjectInBackgroundWithId: XXXX (class 行) 中传递。我该怎么做?

- (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];

}

在PassengerViewController.h中需要写这段代码:

@property (strong, nonatomic) NSString *previoustripObjectID;

在PassengerViewController.m中需要写这段代码:

-

 (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"];
    }];
}