我该如何修复警告

时间:2012-07-07 08:10:13

标签: ios xcode4.2

我的项目中有两个类:SIAViewController.h及其子类cell.h

cell.h我有

@interface cell : UIViewController
@property(nonatomic)CGRect frame;
@property(assign,nonatomic)UIImage *image;
@property(nonatomic)int tag;
@property(nonatomic)bool userInteractionEnabled;
@property(retain,nonatomic)UITapGestureRecognizer *addGestureRecognizer;
@end

SIAViewController.m

int x=20,y=50,t=1;
cell *tank[9][9];
for(int i=1;i<=8;i++)
{
    for(int j=1;j<=8;j++)
    {
        tank[i][j]=[[cell alloc]init];
        tank[i][j].frame=CGRectMake(x, y, 35, 35);
        UIImage *myImage=[UIImage imageNamed:@"s.jpg"];
        [tank[i][j] setImage:myImage];
        tank[i][j].tag=t;
        tank[i][j].userInteractionEnabled=YES;
        UITapGestureRecognizer * recognizer = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapDetected:)];
        tank[i][j]. addGestureRecognizer=recognizer;
        [self.view addSubview:tank[i][j]];
        x+=35;
        t++;
    }
    y+=35;
    x=20;
}

在运行项目时,我收到线程不兼容的指针类型,将单元__strong发送到uiview类型的参数。谁能帮我。我是xcode的新手。感谢

1 个答案:

答案 0 :(得分:1)

原因是,UIView是表视图单元格的超类。这意味着如果某些属性应该是UITableViewCell,但是你传入了一个通用的UIView实例,那么UIView可能(但不一定)也是一个UITableViewCell。这就是编译器警告你的原因。如果您知道要设置的实例实际上是伪装成UIView的UITableViewCell,则可以安全地忽略此警告,因为Objective-C是一种动态语言;类型声明仅用于欺骗编译器;类型匹配在运行时发生。