2011-05-16 2 views
1

다른 프로젝트에서 복사 한 코드와 정확히 같은 코드가 있기 때문에 그 문장에 어떤 문제가 있는지 알 수는 없지만 모든 것이 정상적으로 보일 때 EXC_BAD_ACCESS를 계속 던지고 있습니다. 아무도 문제를 정확히 지적 할 수 있습니까? 이 오류가 몇 시간 동안 있었고 동일한 코드가 잘못된 액세스와 같은 다른 결과를 생성하거나 흰색 화면이 나타나는 등 많은 도움을 받았습니다.EXC_BAD_ACCESS 릴리스 문 사용시의 문제점

코드 조각은 :

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ 

NSLog(@"0"); 
UINavigationController * localNavigationController; 

tabBarController = [[UITabBarController alloc] init]; 
NSMutableArray * localControllersArray = [[NSMutableArray alloc] initWithCapacity:4]; 

//ProductViewController 
ProductViewController * productViewController; 
productViewController = [[ProductViewController alloc] initWithTabBar]; 

localNavigationController = [[UINavigationController alloc] initWithRootViewController: productViewController]; 
[localControllersArray addObject:localNavigationController]; 
NSLog(@"1"); 
// memory statements 
[localNavigationController release]; 
[productViewController release]; 


//Search View Controller 
SearchViewController * searchViewController; 
searchViewController = [[SearchViewController alloc] initWithTabBar]; 
localNavigationController = [[UINavigationController alloc] initWithRootViewController: searchViewController]; 
[localControllersArray addObject:localNavigationController]; 

// memory statements 
[localControllersArray release]; 
[searchViewController release]; 
NSLog(@"2"); 
//Register View Controller 
RegisterViewController * registerViewController; 
registerViewController = [[RegisterViewController alloc] initWithTabBar]; 
localNavigationController = [[UINavigationController alloc] initWithRootViewController:registerViewController]; 

[localControllersArray addObject:localNavigationController]; 
NSLog(@"3"); 
//memory management 
[localControllersArray release]; 
[registerViewController release]; 

//About View Controller 
AboutViewController * aboutViewController; 
aboutViewController = [[AboutViewController alloc] initWithTabBar]; 
localNavigationController = [[UINavigationController alloc] initWithRootViewController: aboutViewController]; 
[localControllersArray addObject:localNavigationController]; 

//memory management 
[localNavigationController release]; 
[aboutViewController release]; 
NSLog(@"4"); 
// Override point for customization after application launch. 
tabBarController.viewControllers = localControllersArray; 


[window addSubview:tabBarController.view]; 
// Override point for customization after application launch. 
[self.window makeKeyAndVisible]; 
return YES; 

NSLog 문제가 어디에 있는지 볼 수 있었다. [localNavigationController release] 이후에는 3이 표시되지 않습니다.

프로젝트를 첨부했습니다. 사전에

http://www.mediafire.com/?eauye5s361cyej0

감사합니다.

+0

대신 코드 조각을 사용 하시겠습니까? – Eimantas

+1

죄송합니다. 전체 프로젝트를 다운로드하여 압축을 풀지 않은 다음 오류가 어디 있는지 추측 할 것입니다. 질문에 몇 가지 코드를 게시하십시오. – JeremyP

답변

2

제품 메뉴에서 "분석"을 사용, 정말 정적 분석기

를 사용하고, 두 번째 내에서 문제를-핀 포인트합니다.

[localControllersArray addObject:localNavigationController]; 

에서

당신은 당신이 전에 몇 가지 라인을 출시 배열을 사용합니다.

편집 : 예, 코드를 게시하는 대신 프로젝트를 업로드하는 것이 좋습니다. 그냥 좋은 하루 보내고 다운로드 한 것 같아요.

[localControllersArray release]; 

당신의 NSLog(@"3"); 문 후 :

2

오류가 함께합니다.

localControllersArray은 이미 NSLog(@"2") 성명 앞에 발표되었습니다.

해결책은 NSLog(@"2") 문 앞에 [localControllersArray release];을 제거하는 것입니다.