Why might an array decoded from plist or JSON not respond to :class or :count while a programmatically created array does?
<p>I'm encountering an extremely vexing problem. I have a UITableViewController which in its init method decodes a dictionary from a JSON or plist file (I've tried both), then retrieves an array from that dictionary. Later on, in the method tableView:numberOfRowsInSection:, I'm returning the count of that array.</p>

<p>However, for reasons beyond me, calling count on the array at that point crashes the application, though calling count directly after assignment in init doesn't. Also, if I replace the initial assignment with a programmatically created array (via NSArray initWithObjects), it works fine.</p>

<p>JSON decoding in init:</p>

<pre><code>NSString *jsonPath = [[NSBundle mainBundle] pathForResource:@"Categories" ofType:@"json"];
SBJSON *jsonParser = [SBJSON new];
NSDictionary* dict = [jsonParser objectWithString:[NSString stringWithContentsOfFile:jsonPath encoding:NSUTF8StringEncoding error:nil]];
categories = [dict objectForKey:@"ContentCategories"];

// Outputs correct count
NSLog(@"Count: %@", [NSNumber numberWithInt:[categories count]]);
</code></pre>

<p>Programmatic init:</p>

<pre><code> categories = [[NSArray alloc] initWithObjects: [[NSDictionary alloc] initWithObjectsAndKeys:@"Junk", @"Title"]];

 // Outputs correct count
NSLog(@"Count: %@", [NSNumber numberWithInt:[categories count]]);
</code></pre>

<p>UITableViewController number of rows method:</p>

<pre><code>// Outputs correctly if programmatically created, crashes if decoded from JSON/plist
NSLog(@"Count: %@", [NSNumber numberWithInt:[categories count]]);
</code></pre>

<p>I've tried the "categories" variable as an ivar, a propertied-ivar, and as a class variable, with no luck.</p>

<p>Thanks for your help!</p>
