How To Find Available Disk Space of iOS Device? Aasim Naseem, February 14, 2012March 12, 2024 Hello iOS fellows; Hope life is as much bright as the retina display of iPhone 4S; (:Well its a Valentine’s night and I’m writing this blog post at mid night, thinking that may be someone get some benefit with these few lines and saved his/her time to googling here and there; Ahh what a priorities of an engineer; (: I was working on an iOS application where I had needed to determine the available disk space on user’s device, to warn the user about storage;Here is the code I used that finds outs the space in bytes;[sourcecode lang=”objc” highlight=”6,7″]+(void)calculateSpaceOnDisk { NSError *error = nil; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES); NSDictionary *dictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:[paths lastObject] error: &error]; if (dictionary) { float freeSpace = [[dictionary objectForKey: NSFileSystemFreeSize] floatValue]; float totalSpace = [[dictionary objectForKey: NSFileSystemSize] floatValue]; } else { NSLog(@"Error Obtaining File System Info: Domain = %@, Code = %@", [error domain], [error code]); } }//end calculateSpaceOnDisk:[/sourcecode]The highlighted lines are soul of this post;Note that I’m storing all of my application’s data in Library/Cache directory, not in /Document; Not sure right now how it may effect on above piece of code;Stay bright;Aasim NaseemI’m an engineer by profession, a blogger and a photojournalist by hobby. Seasonal writer at LAFZ Media UK. I write on different topics and things around us. Contact me at +971.56.126.8842 or Aasim.Naseem@outlook.com iOS Tips & Tutorials available disk spacefind free space in xcodeiPhoneNSFileSystemFreeSizeNSFileSystemSizeNSSearchPathForDirectoriesInDomains