views:

600

answers:

1

I have a question, i carefully went through and thoroughly understood the tutorial at http://developer.apple.com/iPhone/library/documentation/DataManagement/Conceptual/iPhoneCoreData01/Articles/01_StartingOut.html#//apple_ref/doc/uid/TP40008305-CH105-SW1 for iOS Core Data.

The issue was that when i coded everything and run on iOS 4 with multitasking.. the program crashed when i re-opened it (kill task from fast app switching and relaunch)

Then i went curious and recode it on iPad (since it hasnt support multitasking) and it works fine...

I went to explore abit, and some says that the fast app switching kill app is like the OSX kill app and there is applicationTerminate method in the delegate file which maybe need some changes (based on the comment).

Could someone enlighten me on that issue? Is there anything additional that i need to do in order to have Core Data to support the Multitasking feature..

Thank you!

Update

Ok but the thing i am not getting is that.. once i killed the app.. go Fast App Switch, kill it... and when i re-run the app.. it crashed.. Do i need to add some stuff to the multitasking methods? It crashes even if its a basic app with 1 button... What are the states that i have to save?

Update

The app just freeze on its own

Update

Alright my bad, trying my best, for the one button app... I sticked a button in there, and for each click, it prints an NSLog and a label. When i build and run it, it works fine, clicking it prints them normally. After going to background and close the app.. it sends SIGKILL Then when i relaunch the app, it no longer prints to NSLog and crash there 0x98a450f0 <+0000> mov $0xffffffe1,%eax 0x98a450f5 <+0005> call 0x98a453d8 <_sysenter_trap> 0x98a450fa <+0010> ret 0x98a450fb <+0011> nop

Update

However when i open the Iphone simulator and run the program directly... without building it from xcode.. It works just fine and it was able to print that value. Same is true for the Core Data.. if i just run it from the Simulator. Kill it and re-run, it works fine.. Not sure what's going on

+1  A: 

With iOS 4.0, your app may not receive a -applicationWillTerminate call. It may only receive a call to go into the background and then be killed.

When you get the call to go into the background you should dump as much memory as possible to avoid being killed, that includes saving your context and perhaps calling reset on the context to get it to drop its cache.

Other than that, no changes need to be made.

What crash are you seeing, a stack trace would be helpful to explore this further.

Update

Again What crash are you seeing?

Update

Freezes where? Where does it stop when you look at it in Shark or the debugger? You are not giving me a lot of information to go on here :)

Marcus S. Zarra
Ok but the thing i am not getting is that.. once i killed the app.. go Fast App Switch, kill it... and when i re-run the app.. it crashed..Do i need to add some stuff to the multitasking methods? It crashes even if its a basic app with 1 button... What are the states that i have to save?
The app just freeze on its own
For a start, take everything you do in -applicationWillTerminate: and copy it also into -applicationDidEnterBackground:. See if that helps.
Thomas Müller
Alright my bad, trying my best, for the one button app...I sticked a button in there, and for each click, it prints an NSLog and a label.When i build and run it, it works fine, clicking it prints them normally.After going to background and close the app.. it sends SIGKILLThen when i relaunch the app, it no longer prints to NSLog and crash there0x98a450f0 <+0000> mov $0xffffffe1,%eax0x98a450f5 <+0005> call 0x98a453d8 <_sysenter_trap>0x98a450fa <+0010> ret 0x98a450fb <+0011> nop
However when i open the Iphone simulator and run the program directly... without building it from xcode.. It works just fine and it was able to print that value.Same is true for the Core Data.. if i just run it from the Simulator. Kill it and re-run, it works fine..Not sure what's going on
Please update your question with this new information so that it is formatted properly. Thanks.
Marcus S. Zarra