[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
NSCFDate
On Thursday, March 14, 2002, at 09:44 PM, Denise Eatherly wrote:
> ( NSCalendarDate *)startDate
> {
> return [ volumeInfo objectForKey:@"startDate" ];
> }
>
> volumeInfo is a dictionary read in using:
> volumeInfo = [ NSDictionary dictionaryWithContentsOfFile:path ];
>
> It was originally created by this statement:
> volumeInfo = [ NSDictionary
> dictionaryWithObjectsAndKeys:PRODUCT_STYLE, @"product", today,
> @"startDate", [ NSCalendarDate distantFuture ], @"endDate", nil ];
>
> and saved to file by this method:
> [ volumeInfo writeToFile:path atomically:YES ];
It is only possible to store an NSDate in a property list on disk, not a
full NSCalendarDate. So when you read the dictionary back in from the
file, you get an NSDate. (Really it's an NSCFDate, which is a private
subclass of NSDate, but that doesn't matter for your purposes.)
So you need to convert the NSDate to an NSCalendarDate. This should work:
- (NSCalendarDate *)startDate
{
NSDate *date;
date = [volumeInfo objectForKey:@"startDate"];
return [NSCalendarDate dateWithTimeIntervalSinceReferenceDate:[date
timeIntervalSinceReferenceDate]];
}
--
Kurt Revis
krevis@xxxxxxxxxx