Tuesday, 20 August 2013

NSFileManager removeItemAtPath crashes on launch (locks main thread)

NSFileManager removeItemAtPath crashes on launch (locks main thread)

In my app, I call the following code in the ApplicationDidFinishLaunching
method:
NSString *cachePath =
[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask,
YES) lastObject];
[[NSFileManager defaultManager] removeItemAtPath:cachePath error:nil];
I know this isn't much to go on, but this addition is causing my app to
crash on launch. It's never getting past the original launch screen,
leading me to believe that this is somehow blocking the main thread. It's
consistent for a given user, but I can't reproduce it on my end.
The naive solution is just to run it on a background thread, but I'm not
confident that will solve the issue, so I would like to get to the heart
of the problem.

No comments:

Post a Comment