The problem, based on the additional code that you indicated below, is that you have two methods with the same name, but whose parameters do not match, namely - (id)init: (Deck*)deck and - (id)init: (int)newvalue .
This is usually not a problem, but in this case the types are structurally different - a pointer and an int. The compiler can distinguish what you mean based on the type of the recipient, but this only works when it has a static type. For example, if you have:
Hand *h = [Hand alloc]; h = [h init: deck];
This will stop giving you a warning. This is very unusual code, though - alloc and init almost always go on the same line.
Since alloc returns id , not a Hand , he does not know that the init call in [[Hand alloc] init:deck] is Hand , not a Card . For more information on this, see Apple Docs on Static Typing .
The simplest (and smartest) solution is to rename the methods to indicate the type of argument. For example, you can use initWithCardValue: and initWithDeck:
EDIT: Also yes, listen to the suggestions of other messages about the correct behavior inside the init method. (This does not raise a warning, but may cause segfault.)
source share