• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Question about laterDate: and earlierDate:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Question about laterDate: and earlierDate:
      • From: Nick Zitzmann <email@hidden>
    • Re: Question about laterDate: and earlierDate:
      • From: Mike Abdullah <email@hidden>
References: 
 >Question about laterDate: and earlierDate: (From: Paul Bruneau <email@hidden>)
 >Re: Question about laterDate: and earlierDate: (From: Mike Abdullah <email@hidden>)

  • Prev by Date: Re: Kludges when binding to 'value' of Menu Items
  • Next by Date: Re: Class vs +class: Cocoa/Obj-C design question
  • Previous by thread: Re: Question about laterDate: and earlierDate:
  • Next by thread: Re: Question about laterDate: and earlierDate:
  • Index(es):
    • Date
    • Thread