Re: Question about laterDate: and earlierDate:
Re: Question about laterDate: and earlierDate:
- Subject: Re: Question about laterDate: and earlierDate:
- From: Mike Abdullah <email@hidden>
- Date: Tue, 16 Oct 2007 14:35:54 +0100
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]];
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.
Mike.
On 16 Oct 2007, at 13:39, Paul Bruneau wrote:
Hi-
I'm a big fan of laterDate: and earlierDate:.
I use them with NSCalendarDate objects even though the methods
belong to NSDate because NSCalendarDate is a subclass of NSDate and
so I should be able to it seems.
And it seems to work fine, but I do get a compiler warning of:
"warning: passing argument 1 of 'setStartTime:' from distinct
Objective-C type"
Here is my code example:
[selectedOS setStartTime:[testedStartTime laterDate:now]]; //this
line gives the warning
- (void)setStartTime:(NSCalendarDate *)newStartTime //this is the
method I am calling
{
[newStartTime retain];
[startTime release];
startTime = newStartTime;
}
startTime is an NSCalendarDate ivar.
testedStartTime is an NSCalendarDate object locally defined.
now is an NSCalendarDate ivar.
So the compiler seems like it's mad that [testedStartTime
laterDate:now] returns an NSDate maybe instead of an NSCalendarDate?
Do I have to use id in my setStartTime: method to prevent this
warning? It seems like I shouldn't have to due to NSCalendarDate
having inherited the methods from NSDate...
Thank you in advance
_______________________________________________
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
_______________________________________________
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