0
votes

I'm learning objective-c, working through Aaron Hillegass' book "Cocoa Programming for Mac OS X - Third Edition". I'm working in Xcode to develop some of the example code, and keep getting a compiler warning on the last line of this method:

- (void) setEntryDate:(NSCalendarDate *) date {
    [date retain];
    [entryDate release];
    entryDate = date;
}

The warning reads "warning: assignment from distinct objective-c type". What causes this warning? How do I prevent it from happening again?

It doesn't seem to affect execution of the program, but I don't understand what the problem is, or even if there really is a problem (could this just be a paranoid compiler?).

1
Where's the declaration of entryDate? You're missing a piece here...Ana Betts
entryDate is declared in the header file.Brian Willis
The question was actually asking 'what is the declaration of entryDate?'mouviciel
From the header file: @interface LotteryEntry : NSObject { NSCalendar *entryDate; }Brian Willis

1 Answers

2
votes

NSCalendar and NSCalendarDate are indeed distinct types. You should decide which one you want entryDate to be (probably NSCalendarDate, judging by the "date" thing").