iphone - UITableView CustomCell crash on Button Click -
this common question @ though have google , cross check code few times not able figure out crash
*** -[mycustomcell performselector:withobject:withobject:]: message sent deallocated instance 0x96f6980
i have customcell named mycustomcell
xib have 3 buttons facebook,twitter,linkedin. gave them ibaction in customcell class.
when click on of them kind of crash.
i using arc.
in viewcontroller class have cellforrowatindexpath
{ static nsstring *cellidentifier = @"mycustomcell"; mycustomcell *cell = (mycustomcell*)[mytableview dequeuereusablecellwithidentifier:cellidentifier]; if (cell == nil) { nsarray *nib = [[nsbundle mainbundle] loadnibnamed:cellidentifier owner:self options:nil]; cell = (mycustomcell *)[nib objectatindex:1]; } return cell; } mycustomcell.m - (ibaction)facebookpressed:(basebutton *)sender { } - (ibaction)twitterpressed:(basebutton *)sender { } - (ibaction)linkedinpressed:(basebutton *)sender { }
i made mistake today! :) gotta replace 2 lines
nsarray *nib = [[nsbundle mainbundle] loadnibnamed:@"nameofcustomcellnibfile" owner:self options:nil]; cell = [nib objectatindex:1];
you have load loadnibnamed: .xib file's name. thought identifier, regarding name referenced cell instead of nib cell.
hope helps!
Comments
Post a Comment