Error: unrecognized selector sent to instance

I have a custom object, Spaces:

#import "Spaces.h"


@implementation Spaces

@synthesize spaceName;
@synthesize spaceUsers;
@synthesize spaceIcon;
@synthesize spaceID;

@synthesize imageURLString;


- (void)dealloc
{
    [spaceName release];
    [spaceUsers release];
    [spaceIcon release];

    [imageURLString release];

    [super dealloc];
}

@end

My root view controller implements a cellForRowAtIndexPath: and grabs from an NSArray of Spaces:

  • UIButton inside UITableViewCell steals touch from UITableView
  • Crop an image using rectangular box of selected area?
  • UICollectionViewController Programmatically crashing with non-nil layout parameter error
  • How to calculate the age based on NSDate
  • Load UITableView from the bottom
  • Swift - How to present ViewController when tapping button in a custom AlertController
  •     [[cell spaceName] setText:aSpace.spaceName];
        [[cell spaceChatType] setText:@"People"];
        [[cell spaceActiveUsers] setText:aSpace.spaceUsers];
    

    This works fine and I can click to go into the detail view and back to the list, but after maybe 5-6 clicks back and forth between the table view and detail view, I get an error at [[cell spaceName] setText:aSpace.spaceName]; which is

    ‘-[__NSCFSet spaceName]: unrecognized selector sent to instance 0x6047b90′”

    Please help! Any insight will be very appreciated!

    UPDATE:

    I’m still getting the same error but I’ve narrowed it down to the this:

    -I’m creating a detail view controller on didSelectRowAtIndexPath…
    -The detail view is being pushed to the viewcontroller and displays fine, I have a back button added as well.
    -The detail view loads information and refreshes on a timer
    -Pressing the back button goes back to the table list view

    This is the problem my detail view is not being released from memory so the more I go back and forth between the views the more timers were going off simultaneously. I added a check to viewWillDisappear that stops the timer by setting a bool value.

    I noticed that the detail view is not unloading…

    From the RootViewController:

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
        //no longer on initial view
        isinit = NO;
    
        //hide keyboard
        [spacesSearch resignFirstResponder];
    
        if (spaces != nil && spaces.count > 0)
        {
            //set back button reference
            UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Spaces" style:UIBarButtonItemStylePlain target:self action:@selector(returnSpacesList:)];  
            self.navigationItem.backBarButtonItem = backButton;
    
            [backButton release];
    
            DetailViewController *details = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil]; 
    
            //Grab Data from selected Space object and pass to DetailViewController
            Spaces *aSpace = nil;
            if (tableView == self.searchDisplayController.searchResultsTableView)
            {
                if ([self.filteredListContent count] == 0)
                {
                    //self.lastSearchText
                    NSLog(@"Create new space code!");
                }
                else
                {
                    aSpace = [self.filteredListContent objectAtIndex:indexPath.row];
                }
            }
            else
            {
                aSpace = [spaces objectAtIndex:[indexPath row]];
            }
    
            //set title and display
            self.navigationController.title = [NSString stringWithFormat:@"/%@/",aSpace.spaceName];
    
            //pass data
            [details passedValue:aSpace.spaceID :aSpace.spaceName];
    
            [self.navigationController pushViewController:details animated:YES];
    
            [aSpace release];
            [details release];
    
        }
    }
    

    How can I force the detail view to be released from memory?

    Thank you

    2 Solutions Collect From Internet About “Error: unrecognized selector sent to instance”

    It sounds like [cell spaceName] has been autoReleased. I cannot see how you have defined that, but take a look at that part of your code.
    If you need more help, you need to provide more code.

    Perhaps your aSpace = [spaces objectAtIndex:[indexPath row]];
    is not returning a Space object. Perhaps before you try and use it you test to make sure with something like if ([aSpace class] == [Spaces class])