C4在视图之间传递数据

时间:2013-10-21 08:08:39

标签: class methods subclass c4

平, 我在我的应用程序中为不同的视图使用不同的子类。因为我现在正试图将C4Image从一个函数传递到另一个函数。 我的代码如下: 在TakePhoto.m

cropPhoto= [CropPhoto new];
cropPhoto.canvas.frame=CGRectMake(0, 0, self.canvas.width, self.canvas.height);
cropPhoto.canvas.userInteractionEnabled = YES;
[cropPhoto setup:img];

cropPhoto.mainCanvas=self.canvas;
[self.canvas addSubview:cropPhoto.canvas];

img在TakePhoto.h中声明为C4Image

CropPhoto.m中的

我声明了这样的设置功能

-(void) setup:(C4Image)image{
//some code here 
}

在TakePhoto.m中,我收到了错误消息 “'CropPhoto'没有可见的@interface声明选择器'setup'。” 我在通过NSUIntegers的一个子类中做了几乎相同的事情并且它在那里工作。那么我还需要为C4Images做些什么,还是因为我在子类之间传递值?

1 个答案:

答案 0 :(得分:0)

您的-(void)setup:(C4Image *)image;需要在类的.h文件中声明,否则其他任何对象都无法调用它。

你.h应该看起来像:

@interface CropPhoto 
-(void)setup:(C4Image *)image;
@end

原因是setup:(C4image*)...自己实现的自定义方法,所以你需要让它可见。

还有很多其他原因。* 查看产生相同问题的不同方案的以下答案:

https://stackoverflow.com/a/10387710/1218605

https://stackoverflow.com/a/14155178/1218605

https://stackoverflow.com/a/13001909/1218605