Re: Question about laterDate: and earlierDate:
Re: Question about laterDate: and earlierDate:
- Subject: Re: Question about laterDate: and earlierDate:
- From: Paul Bruneau <email@hidden>
- Date: Tue, 16 Oct 2007 09:59:08 -0400
On Oct 16, 2007, at 9:35 AM, Mike Abdullah wrote:
Indeed the compiler has spotted that -laterDate returns an NSDate
rather than NSCalendarDate. Can you be sure that an actual
NSCalendarDate object is being returned? If so, you could something
like this:
[selectedOS setStartTime:(NSCalendarDate *)[testedStartTime
laterDate:now]];
Thank you Mike for your reply. I see that you are "casting" the
response from -laterDate: to be an NSCalendarDate (if I am using the
incorrect term, please excuse me because I come from a different Mac
dev environment than most)
I can be sure of the type that is returned but I agree this isn't the
best thing. I still wonder why is -laterDate: returning an NSDate.
Isn't it true that since NSCalendarDate is a subclass of NSDate it
should have full use of the superclass' methods without this kind of
hassle? We don't get the same problem when we use methods from
NSArray in our NSMutableArrays do we?
However, I should point out that that isn't particularly good
practice really. If you can afford to only target 10.4 and later,
you should really use NSDate and NSCalendar rather than
NSCalendarDate.
I can afford to target 10.4 since this app is for a single user under
my control, but I like the methods that exist in NSCalendarDate. I
heard in Big Nerd Ranch's Cocoa Boot Camp last July that people were
turning away from NSCalendarDate due to localization concerns IIRC.
Is there some documentation from Apple that can fully explain to me
why I shouldn't use NSCalendarDate? I have no such localization
concerns in my case but am still interested.
Thanks again
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden