D
D
deleted-mezhevikin2014-03-19 17:45:30
Cocoa
deleted-mezhevikin, 2014-03-19 17:45:30

How to programmatically clear the cache in (Sandbox/Library/Caches) in ios7?

This method works on the simulator, but does not work on the device:

- (void)cleunupCache
{
    NSFileManager *fm = [NSFileManager defaultManager];
    NSString *cachePath = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)[0];
    NSLog(@"%@", cachePath);
    
    if ([fm fileExistsAtPath: cachePath])
    {
        [fm removeItemAtPath:cachePath error:nil];
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
An, 2014-03-22
@Flanker_4

1) Try to delete not the entire folder, but its contents
2) Are you sure that you need a folder with a cache, and not a temporary folder (Temp), IMHO the data that is being deleted would look more logical there. although....

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question