Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your problem lies elsewhere.</p> <p>I created your <code>Animal</code>, <code>Dog</code>, and <code>Cat</code> classes, and the four cases you have above passed. For reference, here is my code: <a href="http://pastie.org/774468" rel="nofollow noreferrer">http://pastie.org/774468</a></p> <p>It outputs:</p> <pre><code>2010-01-11 19:45:10.259 EmptyFoundation[83698:a0f] [cat isMemberOfClass:[Cat class]] PASSED 2010-01-11 19:45:10.265 EmptyFoundation[83698:a0f] [dog isMemberOfClass:[Dog class]] PASSED 2010-01-11 19:45:10.265 EmptyFoundation[83698:a0f] [cat isKindOfClass:[Animal class]] PASSED 2010-01-11 19:45:10.273 EmptyFoundation[83698:a0f] [dog isKindOfClass:[Animal class]] PASSED </code></pre> <p>EDIT:</p> <p>I suppose there was a slight possibility that your <code>AnimalFarm</code> object was the source of the error, but I just tried creating the animal objects that way and got the same results (code: <a href="http://pastie.org/774480" rel="nofollow noreferrer">http://pastie.org/774480</a>):</p> <pre><code>2010-01-11 19:51:35.144 EmptyFoundation[83741:a0f] [cat isMemberOfClass:[Cat class]] PASSED 2010-01-11 19:51:35.156 EmptyFoundation[83741:a0f] [dog isMemberOfClass:[Dog class]] PASSED 2010-01-11 19:51:35.157 EmptyFoundation[83741:a0f] ![ant isMemberOfClass:[Cat class]] PASSED 2010-01-11 19:51:35.157 EmptyFoundation[83741:a0f] [cat isKindOfClass:[Animal class]] PASSED 2010-01-11 19:51:35.157 EmptyFoundation[83741:a0f] [dog isKindOfClass:[Animal class]] PASSED 2010-01-11 19:51:35.158 EmptyFoundation[83741:a0f] [ant isKindOfClass:[Animal class]] PASSED </code></pre> <p>EDIT #2:</p> <p>Based on your observation that an if...else if statement works but the switch statement does not, I modified the code I posted above to use a switch statement.... and it worked just fine. So my comment/question stands: In your if/switch statements, you're using these constants <code>DOG</code> and <code>CAT</code>. Where are those defined?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload