Unable to delete .zip file from file system.
Error:
NSError *error;
BOOL deleted = [[NSFileManager defaultManager] removeItemAtPath:[DocumentDirectory stringByAppendingPathComponent:[UserDefaults stringForKey:kNCSIOfflineDataFileName]] error:&error];
if (!deleted) {
DebugLog(@"%s %@", __PRETTY_FUNCTION__, error);
}
Code:
NSError *error;
BOOL deleted = [[NSFileManager defaultManager] removeItemAtPath:[UserDefaults stringForKey:kNCSIOfflineDataFilePath] error:&error];
if (!deleted) {
DebugLog(@"%s %@", __PRETTY_FUNCTION__, error);
}
Storing file paths that include the absolute path to an app's documents folder in NSUserDefaults
is a very bad idea.
Here's why:
Instead store just the values after the Documents file root and build the full path every time using NSSearchPathForDirectoriesInDomains
.