PFQuery没有得到识别器

时间:2015-01-13 14:33:43

标签: ios parse-platform pfquery

在第一个PFQuery(乘客)中我得到了几个含义,其中有时相距很远的特殊标识符,它必须在第二个PFQuery(行程)中传输数据。来自第一个标识符的数据必须在getObjectInBackgroundWithId:XXXX(class trip)中传递。我怎么能这样做?

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

}

1 个答案:

答案 0 :(得分:0)

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