NSCalendarDate docs sample code
NSCalendarDate docs sample code
- Subject: NSCalendarDate docs sample code
- From: Diggory Laycock <email@hidden>
- Date: Wed, 8 May 2002 23:39:41 +0100
Hi,
The docs for Foundation's NSCalendarDate have the following sample code
for the method "years:months:days:hours:minutes:seconds:sinceDate:"
You can choose any representation you wish for the time difference by
passing null for the arguments you want to ignore. For example, the
following code fragment computes the difference in months, days, and
years between two dates:
NSCalendarDate *momsBDay = [NSCalendarDate dateWithYear:1936
month:1 day:8 hour:7 minute:30 second:0
timeZone:[NSTimeZone timeZoneWithAbbreviation:@"EST"]];
NSCalendarDate *dateOfBirth = [NSCalendarDate dateWithYear:1965
month:12 day:7 hour:17 minute:25 second:0
timeZone:[NSTimeZone timeZoneWithAbbreviation:@"EST"]];
int years, months, days;
[dateOfBirth years:&years months:&months days:&days hours:null
minutes:nullseconds:null sinceDate:momsBDay];
This code doesn't seem to work unless "null" is replaced by "nil".
Is this an error in the docs or am I being very stupid? What is the
difference between nil and null?
Diggory Laycock.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.