Closed danleechina closed 5 years ago
First thing, that crash handler can't catch every crash. It just catch Objective-C exceptions. While in the real world, crash may occur in any place, with any form.
While you do can catch crash with some framework like plcrashreporter, App will be shutdown not just crash. Things like OOM will do it too. While that happens, you just don't get any callback, right?
So here comes the mmap
and MMKV. You just don't need to worry about crashes and OOMs, data will be saved.
Yeah, it's necessary to use the mmap
.
I create a project named MKB
(Yes, I am sorry 😂) which doesn't use mmap
, but I will consider about using the mmap
in an elegant way.
Thank you for your reply.
Hello, I am an iOS developer.
I have read some source files to know how you create this project. I know that you use
mmap
to save data, the advantage is if the app is crashed, OS will help us care about the saving of the file. And when app is launched, construct theNSDictionary
object manually from the local file.But why you don't use
NSSetUncaughtExceptionHandler(&HandleExceptions);
to handle the crash? And if there is a crash, you can save theNSDictionary
object as a json string to a file. And if there's no crash, you just need to save the object at appropriate time.I think this is more simple and cover the most using cases. But I want to hear your options about this.
Thank you.