gpt4 book ai didi

iphone - 'ActionSheet' 的本地声明隐藏了实例变量

转载 作者:行者123 更新时间:2023-11-29 04:46:05 28 4
gpt4 key购买 nike

针对这三个语句获取三个警告消息

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];

}

知道出了什么问题吗?

最佳答案

首先:变量不是用大写字母书写的。请重命名您的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];
}

关于iphone - 'ActionSheet' 的本地声明隐藏了实例变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9626508/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com