Difference between revisions of "StorageSettings.bundle"

From iPhone Development Wiki
Jump to: navigation, search
(Getting the disk usage as reported by the Settings app)
 
Line 3: Line 3:
  
 
== Getting the disk usage as reported by the Settings app==
 
== Getting the disk usage as reported by the Settings app==
To get the disk usage that is reported in the Storage settings, one can use this code snippet:
+
To get the disk usage that is reported in the Storage settings, one can use this code snippet (note: this won't work in the sandbox):
 
<source lang=Objective-C>
 
<source lang=Objective-C>
 
NSBundle *storageSettingsBundle = [NSBundle bundleWithPath:@"/System/Library/PreferenceBundles/StorageSettings.bundle"];
 
NSBundle *storageSettingsBundle = [NSBundle bundleWithPath:@"/System/Library/PreferenceBundles/StorageSettings.bundle"];

Latest revision as of 21:07, 4 May 2020

StorageSettings.bundle is the preference bundle used to view storage information as of iOS 11.0. The class prefix used by StorageSettings is ST

Getting the disk usage as reported by the Settings app

To get the disk usage that is reported in the Storage settings, one can use this code snippet (note: this won't work in the sandbox):

NSBundle *storageSettingsBundle = [NSBundle bundleWithPath:@"/System/Library/PreferenceBundles/StorageSettings.bundle"];
[storageSettingsBundle load];
STStorageDiskMonitor *monitor = [objc_getClass("STStorageDiskMonitor") sharedMonitor];
[monitor updateDiskSpace];

long long totalDiskSpace = monitor.deviceSize;
long long usedDiskSpace = totalDiskSpace - monitor.lastFree;

// Do stuff with totalDiskSpace and usedDiskSpace