On Mar 20, 2008, at 6:32 PM, K. Darcy Otto wrote:
Thanks for your help; that change did clear up the warning. I want to make sure I understand your explanation though:
All these questions have the same answer. In Objective-C, you can arrange for your messages to go to objects (types) that didn't exist at compile time, so a lot of stuff that seems obvious to the human reader has to be handled more generically. So to express that same thought in the terms of each of your questions:
How is [self.sequent objectAtIndex:lineCount-1] of type "id" as opposed to of type "DeductionLine" (since self.sequent is an NSArray of DeductionLine objects)?
The return of that method is of type "id" because that's how it's declared in NSArray.h (and equally, in the NSArray documentation you probably read while writing this code). The point at this point is not so much "what will be the type of the object when eventually the program runs," but rather "how much can the compiler assume at compilation time?" And the answer is, pretty much nothing: it knows there'll be some sort of object there, but it doesn't know what (that's what "id" means).
Is it that at compilation time, the compiler does not know what sort of object [self.sequent objectAtIndex:lineCount-1] is - but at runtime it turns out to be of type DeductionLine and so that's why everything runs smoothly?
Right.
But when there is the explicit cast accomplished by (DeductionLine *), the compiler then knows what sort of object [self.sequent objectAtIndex:lineCount-1] is?
Something like that. To be finicky: when you put in the cast, the compiler just has to trust you. It doesn't so much "know" the answer at that point, as just take your word for it. If you listen very closely, you'll hear it grumble, under its breath, "OK, then, smarty- pants, let it be on your head!"
When you say the compiler doesn't know which "justification" is going to apply - I take it this is because the Justification object has a justification method. How is it confused, since the class name begins with a capital, and the method begins with a miniscule? Thanks again.
Not a question of "Justification" vs. "justification" (as you say, the spelling change is quite enough to make that distinction clear), but rather of the "justification" you're thinking of, compared to any other "justification" that anyone might ever define in any class that exists now or at any time in the future, and then sneak into this NSArray.
-==- Jack Repenning Chief Technology Officer CollabNet, Inc. 8000 Marina Boulevard, Suite 600 Brisbane, California 94005 office: +1 650.228.2562 mobile: +1 408.835.8090 raindance: +1 877.326.2337, x844.7461 aim: jackrepenning skype: jrepenning _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]