私はビューからポップして元のビューに戻るこのケースがあります。
ボタンを押すとアプリがクラッシュし、コンソールにEXC_BAD_ACCESSが表示されます。ゾンビを有効にして
私は楽器でそれを実行し、これは私が得るものです:それはのdeallocを示されているよう
deallocが2回呼び出されました
link to imageは、同じオブジェクトに対して2回呼び出され。
機器は、NSStrings
を含むNSMutableArray
を指しています。
誰でもこの問題を解決するのに役立つことができます... ありがとうございます。
ps:解決策がthis questionで提供されても問題は解決しません。
編集: この配列は、xmlファイルから解析されたデータで埋められます。
-(void) grabData{
listOfNames=[[NSMutableArray alloc] init];
NSString *XMLPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"chi.xml"];
NSData *XMLData = [NSData dataWithContentsOfFile:XMLPath];
CXMLDocument *rssParser = [[[CXMLDocument alloc] initWithData:XMLData options:0 error:nil] autorelease];
NSArray *items = [rssParser nodesForXPath:@"/template/item" error:nil];
for (CXMLElement *node in items) {
int counter;
if([[[node attributeForName:@"type"] stringValue] isEqualToString:@"label"]){
for(counter = 0; counter < [node childCount]; counter++) {
[listOfNames addObject:[[node childAtIndex:counter] stringValue]];
}
}
...
と、この機能で使用されています
-(void)setupPage{
[scroll setCanCancelContentTouches:NO];
scroll.indicatorStyle=UIScrollViewIndicatorStyleWhite;
scroll.clipsToBounds=YES;
scroll.scrollEnabled=YES;
scroll.pagingEnabled=NO;
int y=Y;
CGFloat cy=0;
int count=[listOfProperties count];
int total=count;
for(int i=0;i<count;i++){
NSString *class=[[[NSString alloc] initWithFormat:@"%@",[(NSObject *)[listOfProperties objectAtIndex:i] class]] autorelease];
if([class isEqualToString:@"textFieldCell"]){
((textFieldCell*)[listOfProperties objectAtIndex:i]).str=[listOfNames objectAtIndex:i];
[((textFieldCell*)[listOfProperties objectAtIndex:i]) setTarget:scroll];
((textFieldCell*)[listOfProperties objectAtIndex:i]).view.frame=CGRectMake(X,y,self.view.frame.size.width - remProfX,cellProfH);
[((textFieldCell*)[listOfProperties objectAtIndex:i]) setImage:[self getImageName:i maxValue:(count-1)]];
[scroll addSubview:((textFieldCell*)[listOfProperties objectAtIndex:i]).view];
}
else{
if([class isEqualToString:@"comboBoxCell"]){
((comboBoxCell*)[listOfProperties objectAtIndex:i]).str=[listOfNames objectAtIndex:i];
[((comboBoxCell*)[listOfProperties objectAtIndex:i]) setTarget:self.view];
((comboBoxCell*)[listOfProperties objectAtIndex:i]).view.frame=CGRectMake(X,y,self.view.frame.size.width - remProfX,cellProfH);
[((comboBoxCell*)[listOfProperties objectAtIndex:i]) setImage:[self getImageName:i maxValue:(count-1)]];
[scroll addSubview:((comboBoxCell*)[listOfProperties objectAtIndex:i]).view];
}
else{
if([class isEqualToString:@"dateCell"]){
((dateCell*)[listOfProperties objectAtIndex:i]).str=[listOfNames objectAtIndex:i];
[((dateCell*)[listOfProperties objectAtIndex:i]) setTarget:self.view];
((dateCell*)[listOfProperties objectAtIndex:i]).view.frame=CGRectMake(X,y,self.view.frame.size.width - remProfX,cellProfH);
[((dateCell*)[listOfProperties objectAtIndex:i]) setImage:[self getImageName:i maxValue:(count-1)]];
[scroll addSubview:((dateCell*)[listOfProperties objectAtIndex:i]).view];
}
}
...
にdealloc:あなたがそれらのいずれかの方法を使用して、自動解放オブジェクトとしてあなたにNSArrayを作成した場合、これが起こっている可能性があります
- (void)dealloc {
[listOfNames release];
[listOfProperties release];
[listOfGroupNames release];
[listOfCheckBoxNames release];
[listOfCheckBoxes release];
[listOfButtons release];
[scroll release];
[super dealloc];
}
あなたは、配列を囲むあなたのコードの一部を投稿することができます:クラスワードは、それはあなたがここでやったようにそれを使用することが悪いですreseverdれるところで
EDIT ? –
@Chris Gregg done。 – astazed
配列を作成してリリースするコードを追加します。特にdeallocメソッド。 – Cyprian