Frage

Okay, so from fresh (app not previously installed on the iPhone simulator), the app boots up fine. Then I press the home button and click on the icon and it also is fine. Then if I press the home button, then close the app from the multitasking bar, then press the icon I get the SIGKILL error.

However, when I press run in Xcode it ALWAYS works flawlessly without fail (even after I have close it from the multitasking bar, where pressing the icon fails). Is this just a quirk with the simulator? This behaviour has only begun after I have implemented some NSUserDefault stuff, to remember it's state etc. It does remember all of the defaults though, when it works.

Any help is appreciated.

EDIT:

- (void)viewDidLoad
{

NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys:
                                 [NSNumber numberWithInt:1], @"firstRun",
                        nil];
[defaults registerDefaults:appDefaults];
if ([[defaults objectForKey:@"firstRun"] intValue] == 1) {
//do the stuff required at first launch
table = [NSMutableArray array];
Stocks =[NSMutableArray array];
Money =1234.56;
mem=@"GOOG";
[defaults setDouble:Money forKey:@"money"];
[defaults setObject:mem forKey:@"ticker"];
[defaults synchronize];
self.Input.text=mem;


- (void)viewWillAppear:(BOOL)animated
{

NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
if ([[defaults objectForKey:@"firstRun"] intValue] == 0) {
    [self entered:nil];

} else if ([[defaults objectForKey:@"firstRun"] intValue]== 1){
    [defaults setObject:[NSNumber numberWithInt:0] forKey:@"firstRun"];
    [defaults synchronize];
}
[super viewWillAppear:animated];
}

Here is what I think may be relavent regarding NSUserDefaults in my MainViewController (I don't use UserDefaults in any other viewController).

I also do a few setObjects/synchronizes in a few other methods, but they only execute when a button is clicked (which doesn't happen when it crashes).

War es hilfreich?

Lösung

When you remove your the application from your multitasking bar, you are actually permanently closing it. Hence you destroy the instance (all processes get killed), which the XCode associated with your app. This is why you get the SIGKILL error.

More on the iPhone Simulator: http://developer.apple.com/library/ios/#DOCUMENTATION/Xcode/Conceptual/ios_development_workflow/25-Using_iOS_Simulator/ios_simulator_application.html

In fact this would even happen if you ran your application on an actual device, and deleted it from the multitasking bar, while the application was connected to XCode. However if your application is installed on a device and not connected to Xcode for running/testing/profiling, the problem won't occur.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top