나는 간단한 아이폰 앱을 가지고 놀았으며 NSLog 문을 컨트롤러와 델리게이트 모두의 dealloc에 넣기로 결정했으나 Xcode 콘솔로 출력하지 않았다.iPhone 대리자 및 컨트롤러 dealloc?
// 응용 대의원
#import "iPhone_buttonFunAppDelegate.h"
#import "iPhone_buttonFunViewController.h"
@implementation iPhone_buttonFunAppDelegate
@synthesize window;
@synthesize viewController;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Override point for customization after app launch
NSLog(@"applicationDidFinishLaunching ...");
[window addSubview:viewController.view];
[window makeKeyAndVisible];
}
- (void)applicationWillTerminate:(UIApplication *)application {
NSLog(@"AWT:");
}
- (void)dealloc {
NSLog(@"-DEL-"); // << Does not print?
[viewController release];
[window release];
[super dealloc];
}
@end
// VIEW CONTROLLER
#import "iPhone_buttonFunViewController.h"
@implementation iPhone_buttonFunViewController
@synthesize statusText;
-(IBAction)buttonPressed:(id) sender {
NSString *title;
NSString *newText;
title = [sender titleForState:UIControlStateNormal];
newText = [[NSString alloc] initWithFormat:@"%@ button pressed.", title];
[statusText setText:newText];
[newText release];
NSLog(@"Button Press ... %@", title);
}
-(void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
NSLog(@"-1-");
}
-(void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
NSLog(@"-2-");
self.statusText = nil;
}
-(void)dealloc {
NSLog(@"-CON-"); // << Does not print?
[statusText release];
[super dealloc];
}
@end
게리
본질적으로 내가 가지고있는 모든 릴리스가 완료되지 않고 있습니다. 정리는 본질적으로 앱이 종료되고 그 풋 프린트가 정리 될 것이라는 사실입니까? – fuzzygoat
이 맞습니다. AppDelegate의 dealloc 메서드는 정상적인 프로그램 작업에서는 호출되지 않습니다. –