Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/8.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 xcode无法识别@property,但它是正确的_Ios_Objective C_Xcode - Fatal编程技术网

Ios xcode无法识别@property,但它是正确的

Ios xcode无法识别@property,但它是正确的,ios,objective-c,xcode,Ios,Objective C,Xcode,Xcode无法识别控制器中的@属性 ViewController2的.m文件: - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([[segue identifier] isEqualToString:@"showDetail"]) { NSIndexPath *selectedIndexPath = [[self.collectionView indexPaths

Xcode无法识别控制器中的
@属性

ViewController2的.m文件:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([[segue identifier] isEqualToString:@"showDetail"])
    {
        NSIndexPath *selectedIndexPath = [[self.collectionView indexPathsForSelectedItems] objectAtIndex:0];

        // load the image.

        NSString *imageNameToLoad = [NSString stringWithFormat:@"%d", selectedIndexPath.row];
        NSString *pathToImage = [[NSBundle mainBundle] pathForResource:imageNameToLoad ofType:@"JPG"];
        UIImage *image2 = [[UIImage alloc] initWithContentsOfFile:pathToImage];

       Detail_ViewController_Biffy *detailViewController = [segue destinationViewController];
    Detail_ViewController_Biffy.**image = image;**  <--- fails [property 'image'not found on object of type 'detail_ViewController_Biffy'
    }
}
试图将导入
ViewController.h
更改为
ViewController\u Biffy.h
,但导致更多错误


如果您需要更多信息,请告诉我。

您正在尝试从类而不是实例获取属性。试一试

Detail_ViewController_Biffy *detailViewController = [segue destinationViewController];
detailViewController.image = image

另外,您拥有的类型表示detail_ViewController2,它不在代码中的任何位置:
image
是一个属性而不是类方法,因此您需要访问它:

detailViewController.image = 
其次,您的
prepareforsgue:sender:
中的
image
不存在。我猜您正在尝试将属性设置为
image2
,您将创建一对队列。在这种情况下,失败的代码行如下所示:

detailViewController.image = image2;
所有属性都是通过类的实例访问的。尽管您可能不知道,但您已经在您的线路上创建了detailViewController实例:

Detail_ViewController_Biffy *detailViewController = [segue destinationViewController];

#在标题中导入
。详细信息_ViewController _Biffy定义在哪里?编辑代码-抱歉!我的错误。我尝试了你建议的代码,仍然说使用了未声明的标识符,尽管它的标识如原始代码所示。这似乎是在暗示以前与该属性相关的名称…:修改问题中的代码并回答最后一句话非常感谢您的回答虽然第二个答案解决了问题是的,这很有效,现在出现了马赫-O型线错误,这是因为我已经复制了一些相同的代码,因为我正在尝试在不同的视图控制器上的不同单元格中显示不同的名称类型。我猜您的链接器错误是由于您放入项目中的类没有正确定位而导致的。但这可能超出了这个问题的范围。为你的两个建议干杯,克服了这个障碍!!明亮的非常感谢
Detail_ViewController_Biffy *detailViewController = [segue destinationViewController];