Iterate through JSON array (App Crashing)
<p>I am trying to iterate trough a JSON array to get both the item key and value.</p>

<p>This is my JSON array:</p>

<pre><code> {
    "ClientData": [{
        "Name": "Michael"
    }, {
        "Last": "Ortiz"
    }, {
        "Phone": "5555555555"
    }, {
        "email": "test@gmail.com"
    }],
    "ClientAccess": [{
        "T-Shirt": "YES"
    }, {
        "Meals": "NO"
    }, {
        "VIP": "YES"
    }, {
        "Registration Completed": "Pending"
    }]
}
</code></pre>

<p>Now, I am trying to iterate through the "ClientData" array, but for some reason the app is crashing with this exception:</p>

<pre><code>  *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString objectForKey:]: unrecognized selector sent to instance
</code></pre>

<p>This is the code I am using to iterate through the JSON array:</p>

<pre><code>NSDictionary* object = [NSJSONSerialization JSONObjectWithData:JSONData options:kNilOptions error:nil];

// Client Profile Data

NSDictionary *clientDataDict = [object objectForKey:@"ClientData"];
for (id item in clientDataDict) 
{
    [JSONUserData addObject:[clientDataDict objectForKey:item]];
}
</code></pre>

<p>This code was working fine when I didn't have each item on the JSON array placed inside an array. I did this to keep a consecutive order on the array.</p>

<p>Can someone give me any pointers on what the problem is?</p>

<p>Thank you!</p>