In most cases, when you get a report on an obsolete method, you look at it in the reference documents and it will tell you which replacement to use.
fileAttributesAtPath: traverseLink: Returns a dictionary that describes the attributes of the POSIX file specified in the specified. (Deprecated in iOS 2.0. Use the OffItemAtPath: error: attributes instead.)
Therefore use attributesOfItemAtPath:error:
Here is an easy way:
NSDictionary *fileDictionary = [[NSFileManager defaultManager] attributesOfItemAtPath:getFilePath error:nil];
A more complete way is:
NSError *error = nil; NSDictionary *fileDictionary = [[NSFileManager defaultManager] attributesOfItemAtPath:getFilePath error:&error]; if (fileDictionary) { // make use of attributes } else { // handle error found in 'error' }
Edit: if you don't know what deprecated means, it means the method or class is deprecated. You must use the new API to perform a similar action.
rmaddy
source share