I am setting the value for the string in the viewdidload method and getting the string value in the button action method the app gets crashed. can I know the reason for crashing and how to pass the values to the method.
in .h file
NSString *test;
in .m file
-(void)viewDidLoad
{
test = [NSString stringWithFormat:@"sample"];
}
-(IBAction) buttonPressed:(id)sender
{
NSLog(@"%@", test);
}
When I pressed the button the app crashes.
Please try using this solution, I think this will help you,
Create Property of
testin.hfile like this,,and
synthesizeit in.mfile like this,now use
testasself.testin .m file like this,Another solution for this is just
retainthatteststring inViewDidLoadalso, I think this will also help you..Hope this will help you..