I have declared an NSDate object in .h part. In .m, in viedDidLoad, I used the following lines and it’s working fine
shownDate = [NSDate date];
shownDate = [shownDate dateByAddingTimeInterval:86400.0];
Then when i click a button, I call the same function inside a function
shownDate = [shownDate dateByAddingTimeInterval:86400.0];
But here it’s crashing. These are the only 3 lines in the program where I have used this function. Can someone tell me why this is happening?
Depends on how you are calling it. My best guess without more code is that shownDate is autoreleased. Try retaining it and then releasing it when you no longer need it.