I made this function that returns the size of file in documents directory, it works but I get warning that I wish to fix, the function:
-(unsigned long long int)getFileSize:(NSString*)path
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *getFilePath = [documentsDirectory stringByAppendingPathComponent:path];
NSDictionary *fileDictionary = [[NSFileManager defaultManager] fileAttributesAtPath:getFilePath traverseLink:YES]; //*Warning
unsigned long long int fileSize = 0;
fileSize = [fileDictionary fileSize];
return fileSize;
}
*The Warning is ‘fileAttributesAtPath:traverseLink: is deprecated first deprecated in ios 2.0’. What is it mean and how I can fix it?
In most cases, when you get a report about a deprecated method, you look it up in the reference docs and it will tell you what replacement to use.
So use
attributesOfItemAtPath:error:instead.Here’s the simple way:
The more complete way is:
Edit: In case you don’t know what deprecated means, it means that the method or class is now obsolete. You should use a newer API to perform a similar action.