在我的应用程序的一个视图中,它是UIView类的子类,我在工具栏上有一个按钮(self.navigationController.toolBar)。一旦按下,UIActionSheet就会弹出'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];
}我不知道为什么我不能从UIActionSheetDelegate方法访问变量。我已经声明了变量并给出了值。
谢谢
发布于 2010-12-18 16:00:17
您是否尝试过:
-(void) viewDidLoad {
...
classVariable = [[NSString alloc] initWithString:@"blah"];
}https://stackoverflow.com/questions/4477205
复制相似问题