ios - addObject in NSMutableArray error -
i trying show or hide buttons actions can take contact depending on whether data present, i.e. there phone number or facebookid. following code compiles crashes on buttonstohide line.
nsmutablearray *buttonstoshow = [nsmutablearray arraywithobjects:self.facebookbutton,self.callbutton, self.smsbutton, self.emailbutton, self.deletebutton, nil]; nsmutablearray *buttonstohide = [nsmutablearray array]; nslog(@"facbook id is:%@",self.contact.facebookid); if (self.contact.facebookid == nil) { [buttonstoshow removeobject:self.facebookbutton]; //following line crashes , shows in green [buttonstohide addobject:self.facebookbutton]; }
would appreciate suggestions on causing crash.
it's isn't crashing on second array allocation, on first, , crash caused 1 elements in initialization being nil.
nsmutablearray *buttonstoshow; if (self.facebookbutton && self.callbutton && self.smsbutton && self.emailbutton && self.deletebutton) { buttonstoshow = [nsmutablearray arraywithobjects:self.facebookbutton,self.callbutton, self.smsbutton, self.emailbutton, self.deletebutton, nil]; } else { buttonstoshow = [nsmutablearray array]; nslog(@"didn't initialize array because placing nil objects in array causes crash"); }
are buttons iboutlets? possibly not hooked up?
Comments
Post a Comment