Reputation: 435
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
Upvotes: 1
Views: 199
Reputation: 6448
Have you tried:
-(void) viewDidLoad {
...
classVariable = [[NSString alloc] initWithString:@"blah"];
}
Upvotes: 1