title: Getting count of children in NSDictionary when sometimes the element is an array and sometimes it's not
body: <p>I have an NSDictionary that looks kind of like this:</p>
  
  <pre><code>list 
     {{
           -&gt; id
           -&gt; name
           -&gt; color
     },
     {
            -&gt; id
            -&gt; name
            -&gt; color
     }}
  </code></pre>
  
  <p>which works great when I loop through it!  But unfortunately, sometimes, the structure looks like this:</p>
  
  <pre><code>list {
     -&gt; id
     -&gt; name
     -&gt; color
  }
  </code></pre>
  
  <p>Where there's only one result returned.  So I need to know if there's one or if there's more than one result returned.</p>
  
  <p>I tried checking for the number of results by seeing if the ID key exists in "list" but unfortunately when I do valueForKey I get back something like this for multiple results:  (429, 24) and just 429 if there's only one result.</p>
  
  <p>But I can't do a count on the 429 value obviously.</p>
  
  <p>Here's one of the things I was trying to do, which works great for multiple results, but not if there's one.</p>
  
  <pre><code>NSInteger numResults = [[list valueForKeyPath:@"id.@count"] intValue];
  </code></pre>
  
  <p>Any idea how to find out if it's an set of results or just a single result?  I don't have any control over the data as it comes from a JSON object via a web service.</p>
  
  <p>I also tried using <code>[list mutableArrayValueForKey:@"id"];</code> and that seems to still only return an array if there's more than one result.  I assumed I'd get back an array with one element if there was only one element...but apparently not?</p>