I try to pass an PFObject with the current ViewController to another ViewController when the user select a cell from the UITableView, this is my code :
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *identifier = @"boxCell";
NSInteger row = [indexPath row];
boxTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if(cell == nil){
cell = [[boxTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
}
PFObject *boxe = [PFObject objectWithClassName:@"Boxe"];
boxe = [self.arrayBox objectAtIndex:row];
PFQuery *query = [PFQuery queryWithClassName:@"Boxe"];
[query whereKey:@"objectId" equalTo:boxe.objectId];
[query getFirstObjectInBackgroundWithBlock:^(PFObject *object, NSError *error) {
if(object){
// I instanciate the PFObject
box = object;
cell.nomBoxe.text = object[@"contenu"];
cell.qteBoxe.text = [NSString stringWithFormat:@"%@ boxes disponbiles",object[@"quantite"]];
cell.prixBoxe.text = [NSString stringWithFormat:@"%@€",object[@"prix"]];
cell.descriptionBoxe.text = object[@"description"];
} else {
NSLog(@"Erreur lors de chargement, erreur : %@",error.description);
}
}];
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[self performSegueWithIdentifier:@"segueToBoxDetail" sender:self];
}
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([[segue identifier] isEqualToString:@"segueToBoxDetail"]) {
boxDetailViewController *boxDetailVC = [segue destinationViewController];
boxDetailVC.box = box;
}
}
I declare the PFObject :
@implementation RestauCardViewController{
PFObject *box;
}
In the other ViewController, I have a property for the object box :
@property(nonatomic) PFObject *box;
I got this error :
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController setBox:]: unrecognized selector sent to instance 0x12aad9100'
Any help please
Aucun commentaire:
Enregistrer un commentaire