我一直在玩一個簡單的iphone應用程序,並決定把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
//視圖控制器
#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 2010-01-17 22:35:34
正確。在正常的程序操作中從不調用AppDelegate的dealloc方法。 – 2010-01-22 03:01:41