다시 컴파일하려고하는 앱을 만들었지 만 다시 재생하려고하면 시뮬레이터가 충돌하고 이유를 파악할 수 없습니다. 다음과 같이 내 코드의 관련 부분은 다음과 같습니다 : 나는 그것이 두 번째 시간이 화면 (다른 화면을 입력 할 때 충돌로 잘못 특별히 GameScreenViewController 뭔가가 있어야합니다 생각하는 Objective-C : 앱이 한 번만 실행되지만 완벽하게 컴파일됩니다.
iFocus2AppDelegate.m
- (void) flipToGameScreen:(NSInteger *)aMode aLevel:(NSInteger*)aLevel
{
NSInteger *myMode = aMode;
NSInteger *myLevel = aLevel;
GameScreenViewController *aGameScreenView = [[GameScreenViewController alloc] initWithNibName:@"GameScreen" mode:myMode level:myLevel bundle:nil];
[self setGameScreenViewController:aGameScreenView];
[aGameScreenView release];
gameScreenViewController.view.frame =[[UIScreen mainScreen] applicationFrame];
//animation
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:window cache: YES];
[viewController.view removeFromSuperview];
[self.window addSubview:[gameScreenViewController view]];
[UIView commitAnimations];
}
GameScreenViewController.m
- (id)initWithNibName:(NSString *)nibNameOrNil mode:(NSInteger *)myMode level:(NSInteger *)myLevel bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self)
{
// Custom initialization.
self.selectedMode = myMode;
self.selectedLevel = myLevel;
}
return self;
}
- (void) finished
{
[myTimer invalidate];
myTimer = nil;
[myTimer release];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"GameOver"
message:@"Do Something"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:nil];
[alert addButtonWithTitle:@"Play Again"];
[alert addButtonWithTitle:@"Show HiScores"];
[alert addButtonWithTitle: @"Setup New Game"];
[alert show];
[alert release];
}
- (void) alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0)
{
//PlayAgain
iFocus2AppDelegate *mainDelegate = (iFocus2AppDelegate *)[[UIApplication sharedApplication] delegate];
[mainDelegate flipToGameScreen:selectedMode aLevel:selectedLevel];
[iFocus2AppDelegate release];
}
if (buttonIndex == 1)
{
//scores
iFocus2AppDelegate *mainDelegate = (iFocus2AppDelegate *)[[UIApplication sharedApplication] delegate];
[mainDelegate flipToHiScores];
[iFocus2AppDelegate release];
}
if (buttonIndex == 2)
{
//setings
iFocus2AppDelegate *mainDelegate = (iFocus2AppDelegate *)[[UIApplication sharedApplication] delegate];
[mainDelegate flipToGameSettings];
[iFocus2AppDelegate release];
}
}
나는이 두 조각을 붙여 (즉, 경고에서 HiScores로) 작업 할 수 있습니다. 다른 코드를 요청할 수 있으면 언제든지 도움을받을 수 있습니다.
(수정 됨) : 요청에 따라 콘솔이 말하는 내용은 다음과 같습니다.
(다시 편집 됨) : 이전에 붙여 넣은 코드는 실제 부분이 아니며, 모든 대답을 읽었음에도 불구하고 유일한 코드 "GDB : 프로그램 수신 신호 : EXC_BAD_ACCESS"가 빌드 & 디버그 일 때 충돌합니다.
오류 보고서의 내용은 무엇입니까? 응용 프로그램이 충돌하면 스택 추적 등이 있어야합니다. –
@Mario,이 코드에 문제가 있다고 생각하지 않지만 https://gist.github.com/1525182에서 수정 한 내용을 확인하십시오. 암호. 내가 추가 한 주석이 달린 행을 읽으십시오. –
@ JackLawrence가 말한 것에 더하여, NSInteger 포인터를 지나치는 것은 아주 이상하고 아마 실수 일 것입니다. 현재보고있는 문제의 원인으로 보이지는 않지만 나중에 문제가 발생할 가능성이 큽니다. – Chuck