Database Reference
In-Depth Information
Since we know the shape of the HTML document, we can build simple XPath
queries to retrieve each part of the document and replace its value component
with data from our metadata in NSDictionary .
Spotlight/QuickLookPlugin/GeneratePreviewForURL.m
QLPreviewRequestSetDataRepresentation(preview,
(CFDataRef)[template XMLData],
kUTTypeHTML,
(CFDictionaryRef)properties);
} @finally {
[pool release], pool = nil;
}
return noErr;
}
Once all the data has been put into the HTML document, it is time to render
it and set the QLPreviewRequestRef . As this section of code shows, we are passing
in the reference along with the HTML file as data and the property NSDictionary .
When this is complete, we pop the NSAutoreleasePool and return noErr . Quick
Look now generates our preview and presents it to the user.
Testing the Quick Look Plug-In
At the time of this writing, testing the Quick Look plug-in is a little more
challenging than testing its Spotlight counterpart. Although there is a com-
mand-line option to test it, getting the system to recognize the plug-in is a
bit trickier. The issue is that the system tends to ignore what generator we
want it to use and will use the generator defined for the system.
In writing this chapter, I used the following workflow to test the Quick Look
plug-in:
1.
Clean and build the main recipe application.
2.
On the command line, execute qlmanage-r to reset the Quick Look
generators.
3.
Run the recipe application, which causes our Quick Look generator to
get registered.
4.
From the command line (can also be done in Xcode), I ran qlmanage-p${path
tometadatatestfile} , which generated the preview. Using the -t switch instead
would produce the thumbnail.
5.
Rinse and repeat.
 
 
 
Search WWH ::




Custom Search