Ok, so the issue is coming from trying to pull data from a sqlite DB and place it in an array for a scroll view display. Im using FM Database library to connect to sql database
The code is as follows:
NSMutableArray *data = [[NSMutableArray alloc] init];
FMResultSet *result = [[[StorageTank sharedStorageTank] DB]
executeQuery:@"SELECT * FROM table"];
while([result next])
{
NSArray *values = [[NSArray alloc] initWithObjects:
[[NSNumber alloc] initWithInt:[result intForColumn:@"id"]],
[[NSNumber alloc] initWithInt:[result intForColumn:@"count"]],
[[NSNumber alloc] initWithInt:[result intForColumn:@"required"]],
[result stringForColumn:@"image_portrait"],
[result stringForColumn:@"image_landscape"],
[[NSNumber alloc] initWithInt:[result intForColumn:@"end_date"]],
[[NSNumber alloc] initWithInt:[result intForColumn:@"active"]],
[result stringForColumn:@"merchant"], nil];
NSLog(@"%@", values);
NSArray *keys = [[NSArray alloc] initWithObjects: @"id",@"count",@"required",
@"image_portrait",@"image_landscape",
@"end_date",@"active",@"merchant",nil];
NSLog(@"%@", keys);
NSDictionary *row = [[NSDictionary alloc] initWithObjects: values forKeys: keys];
[data addObject: row];
}
NSArray *resultArray = [[NSArray alloc] init];
resultArray = data;
So, obviously from the code i’ve tested to make sure the values count is equal to the keys count… yet Im still getting this error:
“Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[__NSPlaceholderDictionary initWithObjects:forKeys:]: number of objects (3) not equal to number of keys (8)'”
I can’t understand for the life of me why the count would differ if when I print out the values array I see 8 values… which should match my 8 keys? and they are correct?
Any help/direction would be greatly appreciated!
Thanks,
Is the fourth item in your values array:
returning
nil? That’s the value that tells -initWithObjects that the list is done.