i want initialize a nsdate with a specific date, to use it in all my code an i'm doing this:
.h
@property (nonatomic, retain) NSDate *myDate;
.m
@synthesize myDate;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy-MM-dd"];
myDate = [formatter dateFromString:@"2050-01-01"];
}
return self;
}
then in the code, if i read that nsdate like in this way:
NSLog(@"%@",myDate);
or if i use isEqualToDate, give me a exc_bad_access
why?