Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/99.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在UITableView中为视图控制器传递数据_Ios_Iphone_Xcode_Uitableview_Parse Platform - Fatal编程技术网

Ios 在UITableView中为视图控制器传递数据

Ios 在UITableView中为视图控制器传递数据,ios,iphone,xcode,uitableview,parse-platform,Ios,Iphone,Xcode,Uitableview,Parse Platform,当用户从UITableView中选择单元格时,我尝试将带有当前ViewController的PFObject传递给另一个ViewController,这是我的代码: -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString *identifier = @"boxCell"; NSInteger row = [index

当用户从UITableView中选择单元格时,我尝试将带有当前ViewController的PFObject传递给另一个ViewController,这是我的代码:

-(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;
    }
}
我宣布该目标:

@implementation RestauCardViewController{
PFObject *box;
}
在另一个ViewController中,我有一个对象框的属性:

@property(nonatomic) PFObject *box;
我得到了这个错误:

由于未捕获异常而终止应用程序 “NSInvalidArgumentException”,原因:”-[UIViewController setBox:]: 已将无法识别的选择器发送到实例0x12aad9100'

请在您的准备工作中提供任何帮助:用此行替换您的声明

boxDetailViewController *boxDetailVC = (boxDetailViewController*)[segue destinationViewController];
编辑 Plz移动

property(nonatomic) PFObject *box; 

在.h文件的第行中

您在错误的位置写入属性。目前您正在类扩展中编写它。类扩展用于仅对该类保密数据

尝试在.h文件中写入相同的属性

在.h文件中声明的属性可供其他类访问。所以其他类可以访问其访问器方法并设置其值


请告诉我。

我也有同样的错误。解决了这个问题,我想在这里分享一下

我有一个UIViewController类,它与segue连接到UITableViewController

事实上,我正在连接segue和UINavigationController


将segue连接更改为UITableViewController解决了问题。

您遇到的错误是什么…我遇到了此错误:由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:'-[UIViewController设置框:]:无法识别的选择器发送到实例0x12aad9100'不确定,但您的box属性可能未分配或未初始化您可以从中显示代码吗boxDetailViewController@VivekMolkar导入boxDetailViewController.h@interface boxDetailViewController@propertynonatomic PFObject*box;@endIt不起作用,但当我删除这一行时,它是否起作用:boxDetailVC.box=box;它肯定会起作用,因为这是抛出错误的那条线。您发布的错误意味着case框中没有此类属性。如果将boxDetailVC.box=nil放入,会发生什么情况?崩溃了?我在.h文件中声明了属性,但它不工作。。。请检查您的故事板中是否有名为setBox的选择器。但它不在代码中。请检查我已检查,但有任何名为setBox的选择器