2
votes


I have a AQGridView , The "initialization" of the grid works great, but when i do [gridView reloadData], it will crash with the error

2012-01-03 21:27:40.338 XXX[8454:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary setObject:forKey:]: attempt to insert nil key'

After a couple of tries i've tracked the error coming from AQGridView's enqueueReusableCells. Its trying to get cell.reuseIdentifier and its value is nil for some weird reason.

Here's the code for gridView:cellForItemAtindex:

- (AQGridViewCell *)gridView:(AQGridView *)aGridView cellForItemAtIndex:(NSUInteger)index{
    static NSString *CellIdentifier = @"SocialCell";
    SocialCell *cell = (SocialCell *) [gridView dequeueReusableCellWithIdentifier:CellIdentifier];


    if (cell == nil){
        cell = [[SocialCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier];

        NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"SocialCell" owner:nil options:nil];

        for(id currentObject in topLevelObjects){
            if([currentObject isKindOfClass:[SocialCell class]]){
                cell = (SocialCell *)currentObject;
                break;
            }
        }
    }

As I said, first run works great, but the second run (reloading the data) , doesnt work as expected. This view includes 7 cells total so it doesn't even actually get dequeued, so i'm not sure why the value would be nil and crash.

Would appreciate any info on this :) Thanks!

OMG! I got the same problem, have you solved it?Lunayo
Im pretty sure i've solved this somehow but i seriously don't remember how. I think i changed the source code in a way to set the reuseIdentifier manually for the specific condition. More of a patch than an actual fix :)Shai Mishali