iphone - Failing to Release after Multiple Nib loads -


i using nib template several buttons. seemed work fine, each have own independent state. when went release buttons crash in dealloc. here code...

msoundbtns = new csoundbutton*[mnumsounds]; for(unsigned int = 0 ; < mnumsounds; ++i) {     msoundbtns[i] = nil; }  for(unsigned int s = 0; s < mnumsounds; ++s) {      [[nsbundle mainbundle] loadnibnamed:@"instancesoundbutton" owner:self options:nil];     //auto loads via outlet 'soundnib'      msoundbtns[s] = soundnib;     soundnib = nil;      uint32 count = msoundbtns[s].retaincount;     nslog(@"last count: %d", count); }   for(unsigned int j = 0; j < mnumsounds; ++j) {     [msoundbtns[j] release];  //**** crash here on 7th (of 8) release     msoundbtns[j] = nil; } 

header:

@interface clocationcontext {    ...     csoundbutton** msoundbtns;    iboutlet csoundbutton* soundnib;  }  @property (nonatomic, assign) iboutlet csoundbutton* soundnib;  @end 

the nib simple, include parent view , child view of custom view type. nib

csoundbutton keeps track of name , boolean state mute or not. here dealloc

- (void)dealloc {      delete[] msoundtag;      // call inherited implementation     [super dealloc];  //****crashes in here } 

the crash inside call super dealloc, in uibutton -> uibuttoncontent dealloc. assume doing poor memory management deallocing twice can't spot where.

is doing loading nib multiple times legal?

you have retain button load nib. if don't, not allowed release later, , won't able access button once code returns control runloop (when autorelease pool drained).

ps: wouldn't easier use cocoa collection (nsmutablearray) store references buttons? code looks complicated me.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -