Hello Everyone,
In one of my view's I have a UIDatePicker. I Also have 2 NSDate*'s initialized in the header (.h) file.
Code:
@interface time : UIViewController {
NSDate* fromDate;
NSDate* toDate;
IBOutlet UIDatePicker *datePicker;
}
@property (nonatomic, retain) NSDate* fromDate;
@property (nonatomic, retain) NSDate* toDate;
@property (nonatomic, retain) IBOutlet UIDatePicker *datePicker;
-(IBAction)dateChanged:(id)sender; //this is linked to the UIdatePicker as an action
in the .m file, I have
Code:
- (IBAction)dateChanged:(id)sender {
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"MMM dd hh:mma"];
if (fromPressed) //either fromPressed or toPressed (Booleans) is True at one time!
{
fromDate = self.datePicker.date;
}
else if (toPressed)
{
toDate= self.datePicker.date;
}
[dateFormat release];
}
The problem is that I cannot set both of these dates from the picker. It only stores the most recently picked date and "corrupts" the other one. I think this is a memory management error (perhaps pointer related?).
Help is appreciated, thanks!