使用或访问 UIActionSheetDelegate 方法中的类变量
在我的应用程序的一个视图(UIView 类的子类)中,我在工具栏上有一个按钮(self.navigationController.toolBar)。一旦按下,UIActionSheet 就会弹出“删除”和“删除”。 '取消'。
myView.h
NSString *classVariable;
....
@property (nonatomic, retain) NSString *classVariable;
myView.m
@synthesize classVariable,...;
-(void) viewDidLoad {
...
classVariable = [[NSString alloc] initWithString:@"blah"];
}
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) {
...
NSLog(classVariable);//BUG HERE!! just cannot printout and app gets sudden death.
}
}
-(void)dealloc{
...
[classVariable release];
}
我不知道为什么无法从 UIActionSheetDelegate 方法访问该变量。我已经声明了变量并给出了值。
谢谢
in one of views in my app, which is subclass of UIView class, I have a button on toolbar(self.navigationController.toolBar). Once pressed, UIActionSheet pops up with 'delete' & 'cancel'.
myView.h
NSString *classVariable;
....
@property (nonatomic, retain) NSString *classVariable;
myView.m
@synthesize classVariable,...;
-(void) viewDidLoad {
...
classVariable = [[NSString alloc] initWithString:@"blah"];
}
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) {
...
NSLog(classVariable);//BUG HERE!! just cannot printout and app gets sudden death.
}
}
-(void)dealloc{
...
[classVariable release];
}
I don't know why I cannot access to the variable from the UIActionSheetDelegate Method. I already declared the variable and give value.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你有没有尝试过:
Have you tried: