Локальное объявление ActionSheet скрывает переменную экземпляра - PullRequest
0 голосов
/ 09 марта 2012

Получение трех предупреждающих сообщений для этих трех операторов

ActionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;

[ActionSheet showInView:self.view ];

[ActionSheet release]; 

Локальное объявление 'ActionSheet' скрывает переменную экземпляра

@property (nonatomic, retain) UIActionSheet *ActionSheet;

@synthesize ActionSheet;


-(void)displayActionSheet:(id)sender

{

UIActionSheet *ActionSheet = [[UIActionSheet alloc] 
                              initWithTitle:@"Language Options"
                              delegate:nil
                              cancelButtonTitle:@"Cancel"
                              destructiveButtonTitle:nil
                              otherButtonTitles:@"Devanagari", @"English", nil];

ActionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;

[ActionSheet showInView:self.view ];

[ActionSheet release];

}

Любая идея, что не так.

1 Ответ

1 голос
/ 09 марта 2012

Первое: переменные НЕ пишутся в верхнем регистре.переименуйте вашу переменную actionSheet.

Второе: ваше свойство имеет то же имя, что и ваша локальная переменная (ActionSheet в вашем случае).Если вы хотите сохранить actionSheet в переменной-члене, то удалите UIActionSheet*, в результате чего эта функция:

-(void)displayActionSheet:(id)sender
{
    ActionSheet = [[UIActionSheet alloc] 
                                  initWithTitle:@"Language Options"
                                  delegate:nil
                                  cancelButtonTitle:@"Cancel"
                                  destructiveButtonTitle:nil
                                  otherButtonTitles:@"Devanagari", @"English", nil];
    ActionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
    [ActionSheet showInView:self.view ];
    [ActionSheet release];
}
...