views:

28

answers:

2

I am getting an error of:

* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull isEqualToString:]: unrecognized selector sent to instance 0x26e9d68'

I have a FriendViewCell class which has a UIImageView and two other labels as an IBOutlet. Setting the property and synthesize it (basic stuffs). I have connected the outlets to the corresponding label and imageview and change the class type to FriendViewCell, set the identity to that as well

The partial code I have is the following:

FriendViewCell *cell = (FriendViewCell *)[tableView dequeueReusableCellWithIdentifier:@"FriendViewCell"];

if (cell == nil) {
    NSArray *topLevelObjects = [[NSBundle mainBundle] 
                                    loadNibNamed:@"FriendViewCell"
                                    owner:nil options:nil];

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

Have you tried to locate what is the instance 0x26e9d68 using the Allocations tracing?

MrZoidberg
A: 

Rather than grabbing the array and searching for your cell, can you simply add an IBOutlet to your tableviewcontroller?

@property (nonatomic, assign) IBOutlet UITableViewCell *tvCell;

then in code:

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"FriendViewCell"];
if (cell == nil) {
    [[NSBundle mainBundle] loadNibNamed:@"FriendViewCell" owner:self options:nil];
    cell = tvCell;
}

You would need to link the IBOutlet to the cell in Interface Builder.

Michael Kernahan