How to properly stop an xCode project currently running?
Asked Answered
M

2

6

This may sound like a silly question, however with the iOS 6 viewDidUnload no longer getting called, I'm interested in how to properly terminate an iOS app currently being debugged with xCode on the development device. Is hitting the stop button below enough?

enter image description here

What exactly happens when I hit that button? Is this the equivalent of sending a stop signal to the app, terminating the app immediately? Does any of the dealloc code gets called? The reason I'm asking is that after repeated debugging with start/stop I'm running into an issue where it appears as if my app is having random memory issues(No leaks are detected with profiling).

Your thoughts are appreciated!

Merrimerriam answered 2/4, 2013 at 16:2 Comment(0)
I
9

Hitting stop kills the app instantly. No dealloc or other code gets called (notably none of your application delegate methods that may be saving data), the process is just terminated. All of the memory used by the process is then freed, and when you start again, you're starting from scratch.

This is unlikely to be the cause of "random memory" problems. If you can give more detail about the symptoms you're experiencing, there could be more to say.

The best way to simulate what a user might do is to hit the home button, then stop the process. This doesn't terminate your app, but you should be dealing with everything necessary when entering the background anyway.

Isoelectronic answered 2/4, 2013 at 16:7 Comment(3)
The problem is described here. #15674036 What you said about memory makes me think that this could also be called by something within core data trying to repair itself after an abrupt termination (I'm using RestKit)Merrimerriam
In my experience Core Data has been very tricky between sessions. If you add a row or object to the table it's usually necessary to either delete the app on the simulator or do iOS Simulator > Reset Content and Settings from the application bar.Vlf
You can just delete the persistent store when you get the error when setting up. Saves a lot of time, and is probably what you'd want in production code anyway.Isoelectronic
A
3

ApplicationWillTerminate is called once application is terminated properly. If you click on the stop button, your application is killed and you might not trace any method calls in that case. As there is no viewDidUnload or dealloc methods for UIViewController, however you can define your own dealloc method without calling the super dealloc.

You could have a look at the Application life Cycle. It might answer lot of questions.

Andromeda answered 2/4, 2013 at 16:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.