I have a pList file:
Root - Dictionary
categories - Array
item 0 - Dictionary
item 1 - Dict
item 2 - Dict
I load the file like so:
-(void) loadCategories
{
// Loads the categories from the SymbolList.plist file
NSString *file = [[NSBundle mainBundle] pathForResource:@"SymbolList" ofType:@"plist"];
NSMutableDictionary *plistSymbolList = [[NSMutableDictionary alloc] initWithContentsOfFile:file];
categoriesList = [plistSymbolList objectForKey:@"categories"];
NSLog(@"count is: %d", [categoriesList count]);
// Here I am just testing if this method will work
for(int i = 0; i < [categoriesList count]; i++)
{
NSDictionary *dict = [categoriesList objectAtIndex:i];
NSLog(@"dict count: %d", [dict count]);
}
// ideally this is what I'd like to do but doesn't work on device
for (NSDictionary *dictionary in categoriesList)
{
if (dictionary == nil)
NSLog(@"It's nil.");
NSLog(@"count: %d", [dictionary count]);
// get and display the category information
NSString *catName = [dictionary objectForKey:@"Category Name"];
NSLog(@"catName is: %@", catName);
NSString *catImage = [dictionary objectForKey:@"Category Image"];
NSLog(@"catImage is: %@", catImage);
NSString *fullFile = [NSString stringWithFormat:@"%@.png", catImage];
NSLog(@"Full file name is: %@", fullFile);
SymbolButton *categoryButton = [[SymbolButton alloc] initWithName:catName andSymbol:catImage];
[categoryButton addTarget:self action:@selector(categoryButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
[categoryButtonList addObject:categoryButton];
NSLog(@"Added Button to list");
}
[self updateCategories];
Just to recap I am: 1) loading the file to get my root 2) getting my list of categories 3) looping through each one and getting some value with either objectAtIndex OR objectForKey
ALL of this code works GREAT on the emulator and runs perfectly with no crashes. This function DIES as soon as I run it on the device:
TestApp[4734:207] count is: 3
TestApp[4734:207] *** -[NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x122d10
TestApp[4734:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x122d10'
From the error message it's saying there is an issue with my instances. But why would this work on the sim and not the device? Everything is updated to the latest SDK and OS version (non-beta) etc.
If I comment out the first for loop I get:
TestApp[4760:207] count is: 3
TestApp[4760:207] *** -[NSCFString count]: unrecognized selector sent to instance 0x120470
TestApp[4760:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFString count]: unrecognized selector sent to instance 0x120470'
Thanks for any and all help. This one is killing me :)