سؤال

I am writing my own library. I want to catch crashes in my library. Library spawns several threads, writes to database, connects to remote servers etc.

My question: IS THERE A POSSIBILITY TO CATCH CRASHES THAT CAUSED ONLY BY MY LIBRARY?

UPDATE 1:

@try/@catch will only handle exceptions that are within method calls

@try {
do smth

//do async task in database

//start sending data to remote server


}
@catch {

}

UPDATE 2:

I want to catch NSExceptions, EX_BAD_ACCESS and, if possible SIGABRT, SIGKILL, low memory etc.

هل كانت مفيدة؟

المحلول

No, this is not possible per library, especially since libraries on iOS will be statically linked into the actual apps. Crashes happen per app process, there is no way to limit a crash reporting library to a subset of an apps code.

Your only option is to test your code as good as possible so that it doesn't have bugs that can cause a crash. Use instruments, static analyzer, write tests.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top