2015-01-13 4 views
0

В первом PFQuery (пассажиры) я получаю несколько значений, среди которых иногда далеко друг от друга специальный идентификатор, который должен передавать данные во втором PFQuery (поездке). Данные из первого идентификатора должны быть переданы в getObjectInBackgroundWithId: XXXX (отключение класса). Как я могу это сделать?PFQuery не получает идентификатор

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

Что именно это ошибка? – soulshined

+0

Мне нужно передать ответ, который исходит от PFQuery * пассажира в PFQuery * trip –

+0

NSLog (@ "% @", ClubWorld); // приносит мне ответ с сервера Parse. [trip getObjectInBackgroundWithId: NEED_INSERT_OBJECT // И здесь мне нужно вставить значение, которое я получил с NSLog Я не могу передать значение, которое я получил. –

ответ

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"]; 
    }]; 
} 
Смежные вопросы