Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Denvildaste

macrumors newbie
Original poster
Apr 7, 2010
8
0
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.
 
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?
 
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.