Posts

Post not yet marked as solved
2 Replies
271 Views
Hi~recently I have storage issue as follows: Go to iOS Settings -> iPhone Storage , it shows available  storage  is enough (ex.180.38 GB) But app will get disk full error when trying to write large file (ex. 26 GB) Error Domain=NSCocoaErrorDomain Code=640 "The file couldn’t be saved because there isn’t enough space." UserInfo={NSUnderlyingError=0x282db8ae0 {Error Domain=NSPOSIXErrorDomain Code=28 "No space left on device"}} Then I write the following  code to log available space and found it is only 26.95 GB available not 180.38 GB as UI displayed NSError *error = nil; NSDictionary *dictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:path error: &error]; NSNumber *sizeValue = [dictionary objectForKey:NSFileSystemFreeSize]; uint64_t totalFreeSpace = [sizeValue unsignedLongLongValue]; print(@“ %@ Free space available.", [NSByteCountFormatter stringFromByteCount:totalFreeSpace countStyle:NSByteCountFormatterCountStyleFile]); Does any one know what reason  may cause this strange situation and how can I do to make available space displayed in UI could be reliable? Any suggestion will be very appreciated!
Posted Last updated
.