Unrecognized selector sent to instance Error

Discussion in 'iOS Programming' started by Denvildaste, Apr 13, 2010.

  1. Denvildaste macrumors newbie

    Joined:
    Apr 7, 2010
    #1
    Hello, I've read a lot about this problem, searching on Google and such, but nothing helped solve mine, I'm not using the IB with this class.

    Inside the .h file I have

    Code:
    -(void) generatePieChart:(id)sender;
    
    And inside the .m file I have

    Code:
    UIButton* infoBarButton = [[UIButton alloc] initWithFrame:CGRectMake(10.0, 280.0, 260, 25)];
    	[infoBarButton addTarget:self action:@selector(generatePieChart:) forControlEvents:UIControlEventTouchUpInside];	
    	[infoBarButton addSubview:infoBarView];
    	[self.view addSubview:infoBarButton];
    
    
    -(void) generatePieChart:(id)sender {
    }
    
    The button shows fine, but whenever I press it I get:

    Code:
    Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFType generatePieChart]: unrecognized selector sent to instance 0x4d80b00'
    
    Now what's confusing me is that this same code used to work, but then I moved this class from a navigation control to a slide control and it stopped working, any help would be appreciated.
     
  2. MrCrispy macrumors member

    MrCrispy

    Joined:
    Apr 10, 2008
    Location:
    Jacksonville, Florida
    #2
    I had a similar error. By any chance have you been playing with the 4.0 sdk beta and not the 3.2 official release?
     
  3. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #3
    Are you sure that "self" is still a valid object once your button is clicked? It could be a memory management bug and you're releasing the object too early.

    Can you post more code?
     
  4. Denvildaste thread starter macrumors newbie

    Joined:
    Apr 7, 2010
    #4
    Hello, sorry for not following up on this thread, I just wanted to let you know how I solved this problem:

    Yes I was releasing the class too early, there's a hint in the error:

    Code:
    [NSCFType generatePieChart]: unrecognized selector sent to instance 0x4d80b00'
    "self" class isn't called NSCFType, as a matter of fact NSCFType is an internal undocumented class in the SDK, the fact that it showed up here means the memory space of my class got freed and this was stored in its location.
     

Share This Page