NSString *folderPath = "give application path here"
Пример: NSString * folderPath = @ "/ private / var / mobile / Applications / 2B63FD7F-2082-415D-A00C-F07C4BE281AA / Example.app";
NSArray *filesArray = [[NSFileManager defaultManager] subpathsOfDirectoryAtPath:folderPath error:nil];
NSEnumerator *filesEnumerator = [filesArray objectEnumerator];
NSString *fileName;
unsigned long long int fileSize = 0;
while (fileName = [filesEnumerator nextObject])
{
NSDictionary *fileDictionary = [[NSFileManager defaultManager] fileAttributesAtPath:[folderPath stringByAppendingPathComponent:fileName] traverseLink:YES];
NSLog(@" fileDictionary %@",fileDictionary);
fileSize += [fileDictionary fileSize];
}
NSLog(@" App Name and App size: %@ : %lld", folderPath,fileSize);
если вы хотите найти размер всех приложений, возьмите путь всех приложений в массиве и напишите оператор цикла для пути к папке
NSArray *applicationsPath="Here array contain all applications path"
for (int i=0; i<applicationPath.count; i++)
{
NSString *folderPath = [applicationPath objectAtIndex:i]
NSArray *filesArray = [[NSFileManager defaultManager] subpathsOfDirectoryAtPath:folderPath error:nil];
NSEnumerator *filesEnumerator = [filesArray objectEnumerator];
NSString *fileName;
unsigned long long int fileSize = 0;
while (fileName = [filesEnumerator nextObject])
{
NSDictionary *fileDictionary = [[NSFileManager defaultManager] fileAttributesAtPath:[folderPath stringByAppendingPathComponent:fileName] traverseLink:YES];
NSLog(@" fileDictionary %@",fileDictionary);
fileSize += [fileDictionary fileSize];
}
NSLog(@" App Name and App size: %@ : %lld", folderPath,fileSize);
}