获取本地声明会为多个语句隐藏实例变量警告消息

时间:2012-06-18 14:28:46

标签: iphone

我无法使用此代码。

声明playpauseButton就在下面给出的语句之上

UIButton *playpauseButton = [UIButton buttonWithType:UIButtonTypeCustom];

获取playpauseButton的本地声明隐藏以下语句的实例变量警告消息

playpauseButton addTarget:self action:@selector(playpauseAction:) forControlEvents:UIControlEventTouchUpInside];
playpauseButton.frame = CGRectMake(0, 0, 30, 30);
[playpauseButton setImage:[UIImage imageNamed:@"Play Icon.png"] forState:UIControlStateNormal];
[playpauseButton setImage:[UIImage imageNamed:@"pause.png"] forState:UIControlStateSelected];
UIBarButtonItem *play = [[UIBarButtonItem alloc] initWithCustomView:playpauseButton];

我定义playpauseAction method

之后
-(void)playpauseAction:(id)sender {    
if( playpauseButton.state == UIControlStateNormal ){
    [sender setImage:[UIImage imageNamed:@"pause.png"] forState:UIControlStateSelected];
[audioPlayer play];
self.timer = [NSTimer scheduledTimerWithTimeInterval:11.0
                                    target:self
                                    selector:@selector(displayviewsAction:)
                                    userInfo:nil
                                    repeats:NO];
}  else if (playpauseButton.state == UIControlStateSelected)
{
[sender setImage:[UIImage imageNamed:@"Play Icon.png"] forState:UIControlStateNormal];
[audioPlayer pause];
 [self pauseTimer];
 } else if (playpauseButton.state == UIControlStateNormal)
{
[sender setImage:[UIImage imageNamed:@"pause.png"] forState:UIControlStateSelected];
[audioPlayer play];
[self resumeTimer];}}

请帮忙。

感谢。

1 个答案:

答案 0 :(得分:3)

它告诉你,你有playpauseButton的两个声明。一个是在类的接口部分(实例变量),另一个是局部变量。

这不是实际错误,但警告告诉您,您可能会得到与您想要的结果不同的结果。