Xcode 4.2 및 최신 SDK를 사용하여 iPhone 및 iPad 어플리케이션을 개발 중입니다.나에 의해 생성 된 오브젝트 공개하기
나는 ARC를 사용하지 않고 탭 응용 프로그램을 작성하고 난 AppDelegate
에이를 발견했습니다
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
UIViewController *viewController1, *viewController2;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
viewController1 = [[[FirstViewController alloc] initWithNibName:@"FirstViewController_iPhone" bundle:nil] autorelease];
viewController2 = [[[SecondViewController alloc] initWithNibName:@"SecondViewController_iPhone" bundle:nil] autorelease];
} else {
viewController1 = [[[FirstViewController alloc] initWithNibName:@"FirstViewController_iPad" bundle:nil] autorelease];
viewController2 = [[[SecondViewController alloc] initWithNibName:@"SecondViewController_iPad" bundle:nil] autorelease];
}
self.tabBarController = [[[UITabBarController alloc] init] autorelease];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, nil];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
내가 viewController1 및 viewController2을 해제해야 할 수 있습니까?
아니요, 'autorelease' 메시지가 전송 되었기 때문에 없습니다. –
다른 사람들은 당신이보기 컨트롤러에 보낸'autorelease'에 대해서 언급했습니다. 언급 할 가치가있는 또 다른 것은'arrayWithObjects'가 그 내용을 유지하기는하지만, autoreleased 상태 자체에서 반환된다는 것입니다. 그래서'tabBar'의 retain은 파괴로부터 그것을 지키는 유일한 것입니다. 귀하의보기 컨트롤러를 공개하는 방법은 다음과 같습니다 : tabBarController -> 컨트롤러의 NSArray ->보기 컨트롤러. – dasblinkenlight