Database Reference
In-Depth Information
metadata = [NSDictionary dictionaryWithContentsOfURL:(NSURL*)url];
NSString *pathToImage = [metadata valueForKey:@ "kPPImagePath" ];
if (!pathToImage) {
//No image available
return noErr;
}
NSData *imageData = [NSData dataWithContentsOfFile:pathToImage];
if (!imageData) {
//Unable to load the data for some reason.
return noErr;
}
QLThumbnailRequestSetImageWithData(thumbnail, (CFDataRef)imageData, NULL);
} @finally {
[pool release], pool = nil;
}
return noErr;
}
In this method, we are again retrieving the metadata file and loading it into
an NSDictionary . From that dictionary, we are retrieving the path to the image
for the recipe and loading the image into an NSData object. From there, we call
the QLThumbnailRequestSetImageWithData(QLThumbnailRequestRef,CFDataRect,CFDictionaryRef)
method, which populates the QLThumbnailRequestRef . After that is done, we pop
the NSAutoreleasePool and return noErr . From there, Quick Look uses the image
we have provided whenever it needs a thumbnail for the file.
Generating the Quick Look Preview
The Quick Look preview is understandably more complex than generating a
thumbnail image. If we do absolutely nothing for this part of Quick Look, we
would still get a rather satisfying preview, as shown in the figure below. But
why stop there when we can do so much more?
 
 
Search WWH ::




Custom Search