Like many of iOS developers I have encountered the issue with application crashing on system before 5.1 when using NSURLIsExcludedFromBackupKey
.
It was well described how to evaluate existence of this key on this thread:
Use NSURLIsExcludedFromBackupKey without crashing on iOS 5.0
One of samvermette's comments says that there is a bug in iOS simulator.
Nevertheless I have encountered the same issue with a Release build, even in 2 separate applications. After some investigation I have discovered that application crashed even before main() method beeing called. Which hinted me that this is connected with
NSString * const NSURLIsExcludedFromBackupKey;
evaluation at application launch.
I am not an expert in this field, but I have found out that, if any reference to const
value occurs in code (even if it is not actually accessed in runtime) this const
is evaluated at very application launch. And this simply causes that crash that many of us experience.
I would like to ask you for some help. Maybe you know a way how to 'weakly' refer to a const value, or maybe there is specific compiler flag. (Using Apple LLVM 3.1).
Thanks in advance.
Please do not comments to put this const's value directly which is @"NSURLIsExcludedFromBackupKey" in this case. I am aware of this workaround, reson for this story is to find a general solution.