I am trying this in my cocoa app to get the information of directory/Files in system. This method return me a dictionary with some key attribute listed
-(NSDictionary *) metadataForFileAtPath:(NSString *) path {
NSURL *url = [[[NSURL alloc] initFileURLWithPath:path] autorelease];
MDItemRef itemRef = MDItemCreateWithURL(NULL, (CFURLRef)url);
NSArray *attributeNames = (NSArray *)MDItemCopyAttributeNames(itemRef);
NSDictionary *attributes = (NSDictionary *) MDItemCopyAttributes(itemRef, (CFArrayRef) attributeNames);
CFRelease(itemRef);
// probably it is leaking memory (attributeNames and attributes), better check with Instruments
return attributes;
}
Another method...
NSDictionary *dict = [self metadataForFileAtPath];
NSString *date = [dict objectForKey:kMDItemFSCreationDate];
When I do this I got a warning message " Incompatible pointer types sending 'const CFStringRef' (aka 'const struct __CFString *const') to parameter of type 'id' " I am trying to type cast them into string but it still exist. I didn't get where I am wrong.
My Problem is solved by doing this
NSString *date = [dict objectForKey:@"kMDItemFSCreationDate"];
Anyway thanks for your help.