Le fileCreationDate est en effet partie du dictionnaire. Voici une méthode qui passe un fichier URI et récupère certains des attributs du fichier:
- (NSDictionary *) attributesForFile:(NSURL *)anURI {
// note: singleton is not thread-safe
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *aPath = [anURI path];
if (![fileManager fileExistsAtPath:aPath]) return nil;
NSError *attributesRetrievalError = nil;
NSDictionary *attributes = [fileManager attributesOfItemAtPath:aPath
error:&attributesRetrievalError];
if (!attributes) {
NSLog(@"Error for file at %@: %@", aPath, attributesRetrievalError);
return nil;
}
NSMutableDictionary *returnedDictionary =
[NSMutableDictionary dictionaryWithObjectsAndKeys:
[attributes fileType], @"fileType",
[attributes fileModificationDate], @"fileModificationDate",
[attributes fileCreationDate], @"fileCreationDate",
[NSNumber numberWithUnsignedLongLong:[attributes fileSize]], @"fileSize",
nil];
return returnedDictionary;
}
Salut Greg - ça fait 2 ans, comment ça va? : D – memmons
Pour être honnête, je ne sais pas si votre solution a résolu mon problème! (Je ne m'en souviens plus.) Le problème que je rencontrais n'était pas le code pour accéder à la date de création; c'est que la date de création n'était simplement pas retournée comme l'un des attributs du fichier. –
LOL, mec, vous êtes dur! – memmons