0

次のコードは、リリースがコメント化されていない場合、tableView didSelectRowAtIndexPathにあり、エラーが発生します。

ComicDetailsViewController * comicDetailsViewController = [[ComicDetailsViewController alloc] initWithNibName:@"ComicDetailsViewController" bundle:nil];
       comicDetailsViewController.comic = (Comic *)[arrayOfComics objectAtIndex:indexPath.row];
       comicDetailsViewController.bLoadPerformances = YES;
       [self.navigationController pushViewController:comicDetailsViewController animated:YES];
       //[comicDetailsViewController release];

エラーはすぐには発生しません。omicDetailsViewControllerの[戻る]ボタンをクリックすると発生します。

つまり、テーブルビューの行を選択すると、次のビューが読み込まれ、正しく機能します。そのビューが終了し、戻るナビゲーションボタンをクリックすると、プログラムがクラッシュし、exc_bad_accessが表示されます。どうしてこれなの?

編集:

#0  0x9682b176 in __kill
#1  0x9682b168 in kill$UNIX2003
#2  0x968bd89d in raise
#3  0x968d39bc in abort
#4  0x968c2164 in szone_error
#5  0x968c21e7 in free_small_botch
#6  0x000a7877 in -[NSConcreteMutableData dealloc]
#7  0x00006433 in -[ComicDetailsViewController dealloc] at ComicDetailsViewController.m:376
#8  0x003cbcc7 in -[UINavigationController setDisappearingViewController:]
#9  0x003c9219 in -[UINavigationController _clearLastOperation]
#10 0x003c9b62 in -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:]
#11 0x0055224a in -[UINavigationTransitionView _notifyDelegateTransitionDidStopWithContext:]
#12 0x0055338a in -[UINavigationTransitionView _navigationTransitionDidStop]
#13 0x0034829d in -[UIViewAnimationState sendDelegateAnimationDidStop:finished:]
#14 0x0034812f in -[UIViewAnimationState animationDidStop:finished:]
#15 0x0244ca28 in run_animation_callbacks
#16 0x0244c8e9 in CA::timer_callback
#17 0x02688d43 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__
#18 0x0268a384 in __CFRunLoopDoTimer
#19 0x025e6d09 in __CFRunLoopRun
#20 0x025e6280 in CFRunLoopRunSpecific
#21 0x025e61a1 in CFRunLoopRunInMode
#22 0x02f0c2c8 in GSEventRunModal
#23 0x02f0c38d in GSEventRun
#24 0x00326b58 in UIApplicationMain
#25 0x000020f4 in main at main.m:14

編集2:

これがcomicDetailsViewControllerdeallocブロックです。

- (void)dealloc {
[comic release];
[xmlParser release];
[webData release];
[currentPerformanceObject release];
[arrayOfPerformances release];
[soapResults release];
[btnPerformances release];
[super dealloc];

}

376行目はwebDataリリースラインです

編集3:

    -(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
    NSLog(@"ERROR with theConenction");
    [connection release];
    [webData release];
}

-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
    NSLog(@"DONE. Received Bytes: %d", [webData length]);

    if(xmlParser)
    {
        [xmlParser release];
    }

    xmlParser = [[NSXMLParser alloc] initWithData: webData];
    [xmlParser setDelegate: self];
    [xmlParser setShouldResolveExternalEntities: YES];
    [xmlParser parse];

    [connection release];
    [webData release];
}
4

3 に答える 3

1

スタックトレースを表示してください。

- (void) deallocしかし、私の最初の推測では、あなたはComicDetailsViewControllerクラスで何か間違ったことをしていると思います。

いくつか確認してください

  • あなたのdeallocブロックは大丈夫です
  • comicDetailsViewControllerオブジェクトまたはその参照を他の場所から解放していません。

お役に立てれば。

ありがとう、Madhup

于 2010-11-26T05:07:35.280 に答える
0

ビューをポップアウトする前に、キャンセルメッセージを適切なオブジェクトに送信して、NSURLConnectionをキャンセルします。

NSURLConnectionオブジェクトの名前がasyncConnectionであると仮定します。

-(void)viewWillDisappear:(BOOL)animated
   [asyncConnection cancel];
}
于 2010-11-26T07:48:49.957 に答える
0

問題はまだおそらくあなたのdeallocにあります。

オブジェクトが@interface(.hファイル)にあるからといって、それは変数の割り当てを解除できる/しなければならないという意味ではありません。私もこの問題を抱えていました

.hファイル

@interface PeopleViewController : UITableViewController {
NSArray *people;
}

@property (nonatomic, retain) NSArray *people;

@end

.mファイル

@implementation PeopleViewController

@synthesize people;

- (void)viewDidLoad {
    people = [town.people allObjects];
}

...

- (void)dealloc {
    [people release];
}

@end

カスタムビューにあるときにオブジェクトの保持カウントを増やしなかったため、人を解放する必要はありませんでした。そのため、deallocプロセス中にオブジェクトを解放すると、問題が発生しました。

于 2010-11-29T11:42:15.597 に答える