Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- __dataArea = [NSMutableData data];
- __unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:__dataArea];
- __archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:__dataArea];
- __iDates = [[BCimportantDates alloc] initWithCoder:[NSKeyedUnarchiver unarchiveObjectWithFile: @"firstDate.arch"]];
- if ((__iDates.firstDate == nil)){
- NSDate *date = [NSDate date];
- NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier: NSGregorianCalendar];
- NSDateComponents *components = [gregorian components: NSUIntegerMax fromDate: date];
- NSLog(@"the date %@",date);
- [components setHour: 3];
- [components setMinute: 00];
- [components setSecond: 00];
- __newDate = [gregorian dateFromComponents: components];
- [__iDates setFirstDate: __newDate];
- NSLog(@"%@",__iDates.firstDate);
- [__iDates encodeWithCoder: __archiver];
- [__archiver finishEncoding];
- if ([__dataArea writeToFile:@"firstDate.arch" atomically:YES] == NO){
- NSLog(@"archiving failed. ");
- }
- }
- - (void) encodeWithCoder:(NSCoder *)encoder{
- [encoder encodeObject: __firstDate forKey: kfirstDateKey];
- }
- - (id) initWithCoder: (NSCoder *) decoder{
- if (self = [super init]) {
- self.firstDate = [decoder decodeObjectForKey:kfirstDateKey];
- }
- return self;
- }
- NSString *path = [NSTemporaryDirectory() stringByAppendingPathComponent:@"firstDate.arch"];
- if ([__dataArea writeToFile:path atomically:YES] == NO){
- NSLog(@"archiving failed. ");
- }
Add Comment
Please, Sign In to add comment