I can't figure out, how to access to properties(I mean file attributes that we ask as NSArray in includingPropertiesForKeys:
part of this method) that I mention in NSFileManager method:
-(NSArray *)contentsOfDirectoryAtURL:<#(NSURL *)#>
includingPropertiesForKeys:<#(NSArray *)#>
options:<#(NSDirectoryEnumerationOptions)#>
error:<#(NSError *__autoreleasing *)#>
I get a NSArray object contains an array of NSURL objects to files.
So, I can't just get this properties(I just don't know how).
I must use this construction for getting that properties:
NSArray *arrayOfNSURLs = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:myFolderURL
includingPropertiesForKeys:@[NSURLContentModificationDateKey, NSURLVolumeIdentifierKey, NSURLLocalizedNameKey,NSURLLocalizedTypeDescriptionKey]
options:NSDirectoryEnumerationSkipsHiddenFiles
error:nil];
// I will call all below this 'second part'
id test;
for (id file in arrayOfNSURLs) {
if ([file isKindOfClass:[NSURL class]]) {
[file getResourceValue:&test forKey:NSURLContentModificationDateKey error:nil];
NSLog(@"%@ %@",file ,test);
}
}
As you can see I must use NSURL method getResourceValue:forKey:error:
. But wait a minute, for what I mention this key in NSFileManager
method contentsOfDirectoryAtURL:includingPropertiesForKeys:options:error:
, in includingPropertiesForKeys:
part???
I try to put nil
as argument for ...includingPropertiesForKeys:
part and there is no difference between adding array of keys and nil, "second part" will give you content modification key anyway.
So, my question is simple: why the need of property for keys argument in contentsOfDirectoryAtURL:includingPropertiesForKeys:options:error:
method?
And is there a way to retrieve information mentioned in this keys without second part in my code?
Thanks.