I know this isn’t exactly the place to post this question but I’ve been banging my head all morning to no avail. I’m trying to get the metadata of an image file (tif or eps) but I keep getting null for the dictionary that should hold that data.
-
(void)tableViewSelectionDidChange:(NSNotification *)notif {
NSDictionary* metadata = [[NSDictionary alloc] init];
//get selected item
NSString* rowData = [fileList objectAtIndex:[tblFileList selectedRow]];//set path to file selected
NSString* filePath = [NSString stringWithFormat:@“%@/%@”, objPath, rowData];//declare a file manager
NSFileManager* fileManager = [[NSFileManager alloc] init];//check to see if the file exists
if ([fileManager fileExistsAtPath] == YES) {//escape all the garbage in the string NSString *percentEscapedString = (NSString *)CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)filePath, NULL, NULL, kCFStringEncodingUTF8); //convert path to NSURL NSURL* filePathURL = [[NSURL alloc] initFileURLWithPath:percentEscapedString]; //also getting a warning here that NSURL might not accept this method, but its in the docs. NSError* error; NSLog(@"%@", [filePathURL checkResourceIsReachableAndReturnError:error]); //declare a cg source reference CGImageSourceRef sourceRef; //set the cg source references to the image by passign its url path sourceRef = CGImageSourceCreateWithURL((CFURLRef)filePathURL, NULL); //set a dictionary with the image metadata from the source reference metadata = (NSDictionary *)CGImageSourceCopyPropertiesAtIndex(sourceRef,0,NULL); NSLog(@"%@", metadata); [filePathURL release];
} else {
[self showAlert:@"I cannot find this file."];
}
[fileManager release];
}
Any help would be appreciated.