views:

549

answers:

4

Hi there,

My iPhone application occasionally crashs the first time it is run after being installed. After this every time i try and run the app it remains on the splash screen or even a black screen until eventually it dies. I have to restart the device to get the application to work. After this it works fine every time. The only change between the OS3 code and 4 is the property 'UIApplicationExitsOnSuspend' to force the app to reload every time instead of suspending. Any help would be great.

Here are the two Code snippets:

- (void)applicationDidFinishLaunching:(UIApplication *)application 
{  
    taskListViewController = [[TaskListViewController alloc] initWithNibName:@"TaskListView" bundle:nil];
    taskListViewController.managedObjectContext = self.managedObjectContext;

    [taskListViewController setAppDefaults];

    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:taskListViewController];
    [taskListViewController release];

    navController.navigationBar.tintColor = [UIColor blackColor];

    [window addSubview:[navController view]];
    [window makeKeyAndVisible];

}

- (void)viewDidLoad 
{
    NSLog(@"viewDidLoad - Start");
    [super viewDidLoad]; 

    NSError *error = nil;
    if(![[self fetchedResultsController] performFetch:&error])
    {
     NSLog(@"Error with initial fetch %@, %@", error, [error userInfo]);
    }

    [activityIndicator startAnimating];

    self.navigationItem.leftBarButtonItem.enabled = NO;
    self.navigationItem.rightBarButtonItem.enabled = NO;
    infoButton.enabled = NO;
    syncButton.enabled = NO;

    taskListTable.userInteractionEnabled = NO;
    taskListTable.allowsSelection = NO;

    checkingRecovery = true;
    [self insertCheck];
}

Other Methods mentioned above:

    [taskListViewController setAppDefaults]
    [self insertCheck];

setAppDefaults - Enumerates through the settings bundle applying the defaultValues to NSUserDefaults if they have not been set already by the user in peferences.

insertCheck - Performs some queries on the db to ensure file integrity on audio recordings but in this case as this is the first time the app is loaded it will do nothing.

Update:

I have commented out the extra method calls (the two above) and i am still having the problem.

I have found a few people having the same sort of problem on the apple developer forum with no solutions. One reply was from a user having the same problem but there application did get approved on the app store.

Thanks Sj

A: 

Have you looked at the log files?

You can copy them off your iPhone if you plug it in, load organizer (Windows->Organizer in XCode) and select device logs.

If you see a log for the time your application crashed, it should include the call stack (which should include the function causing it to crash)

Alternatively it could be that you're stuck in some code run at startup - and if your application doesn't start in a timely manor (within 30 seconds IIRC) iOS kills it.

John Sibly
It doesn't appear to have any crash logs regarding the application. Thanks.
Sjblack
Something else i have noticed is that uninstalling the app and reinstalling it without restarting the device doesn't fix the problem! Thanks again.
Sjblack
A: 

Try it without the managedObjectContext piece and see if you are still crashing. What does the log say when you crash? Do you get a memory exception?

gschaetz
A: 

Got this same problem on our game iCopter Classic. We are still unable to fix.

codetiger
I'm still having the problem too. We have currently put the issue on hold and submitted our app to Apple which has been approved.
Sjblack
@SjblackYes, same here... But lots of users complaining about the issue... We are still not able to fix the issue....
codetiger
+1  A: 

If you are debugging the application when it crashes, you should get a stack trace, which will show you on what line the application crashes.

If you could provide the stack trace it would be much easier to find the cause of the crash.

Erik B
I'm afraid when it crashes it hasn't reached the entry point of the app in code so don't get any crash logs at all. Thanks - Sj
Sjblack