Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It says what the error is in the error message.</p> <p>You have a class <code>My_Entity_Name</code>. An instance of <code>My_Entity_Name</code> is assigned to the property <code>self.entityArray</code>. When you do <code>for (MyEntityType *entityType in self.entityArray)</code>, it passes the <code>-countByEnumeratingWithState:objects:count:</code> message to the instance, and you get the unrecognized selector error.</p> <p>I would look for places where the the value is assigned (either <code>self.entityArray = …</code> or <code>[self setEntityArray:…]</code>) to figure out how <code>self.entityArray</code> is getting the bad value. Perhaps you should post how you are doing the fetch, or if there are other ways that <code>self.entityArray</code> can get assigned a value.</p> <hr> <p><strong>UPDATE</strong></p> <p>I'm not sure what <code>-[Singleton retrieveEntity:]</code> does. It's not a class that's a part of the standard framework, and I don't know of any 3rd party library which uses such generic naming.</p> <p>What I can tell you is that based on the method name <code>-retrieveEntity:</code>, it looks like it returns a single object not an array of objects. Usually methods that return arrays are pluralised, so I would have expected the name to be more like <code>-retrieveEntities:</code>.</p> <p>You got an exception because is because <code>self.entityArray</code> doesn't contain an <code>NSArray</code>. The method name doesn't look like it would return an array.</p> <p>Are you absolutely sure that <code>[[Singleton sharedInstance] retrieveEntity:…]</code> should return an <code>NSArray</code>? Perhaps you should post the code for <code>-retrieveEntity:</code>.</p> <hr> <p><strong>UPDATE</strong></p> <p>You are not returning an array.</p> <pre><code>NSArray *items = [context executeFetchRequest:fetchRequest error:&amp;error]; if ([items count]&gt;0) { return items[0]; } else { return nil; } </code></pre> <p>If the items array has any elements, then the first element is returned. This is what <code>items[0]</code> does.</p> <p>If you want to return the array change it to:</p> <pre><code>NSArray *items = [context executeFetchRequest:fetchRequest error:&amp;error]; if ([items count]&gt;0) { return items; } else { return nil; } </code></pre> <p>Notice I've replaced <code>return items[0];</code> (return the first element of the array) with <code>return items;</code> (return the whole array).</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. 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