Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>isMemberOfClass:</code> will only return <code>YES</code> if the instance's class is exactly the same, however <code>isKindOfClass:</code> will return <code>YES</code> if the instance's class is the same, or a subclass of the given class.</p> <p>For example this will output <code>No!</code>:</p> <pre><code>BOOL result = [[NSMutableArray array] isMemberOfClass:[NSArray class]]; NSLog (@"%@", result? @"Yes!" : @"No!"); </code></pre> <p>But this will output <code>Yes!</code>:</p> <pre><code>BOOL result = [[NSMutableArray array] isKindOfClass:[NSArray class]]; NSLog (@"%@", result? @"Yes!" : @"No!"); </code></pre> <p>This is because an NSMutableArray is a <em>kind</em> of NSArray, but it isn't a member of the NSArray class (otherwise it wouldn't be an NSMutableArray).</p> <p>Throughout Foundation and Cocoa, there are a number of "class clusters". You can read more about this in the documentation on <a href="http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaDesignPatterns/CocoaDesignPatterns.html#//apple_ref/doc/uid/TP40002974-CH6-SW32" rel="noreferrer">Apple's developer web site</a>. Due to the nature of class clusters, if you create perhaps an <code>NSString</code> object, it may fail the <code>isMemberOfClass:[NSString class]</code> test.</p> <p>If neither <code>isKindOfClass:</code> or <code>isMemberOfClass:</code> is returning the correct value, see what class the actual object is with</p> <pre><code>NSLog(@"cat class = %@, dog class = %@", [cat className], [dog className]); </code></pre> <p>If these are returning anything other than what they are supposed to, then there is a problem with your farm class.</p>
    singulars
    1. This table or related slice is empty.
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. 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