<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>CocoaDust &#187; Spotlight</title>
	<atom:link href="http://cocoadust.com/tags/spotlight/feed/" rel="self" type="application/rss+xml" />
	<link>http://cocoadust.com</link>
	<description>Cocoa, Macs, Web, User Experience and more…</description>
	<lastBuildDate>Sat, 24 Nov 2007 15:49:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Spotlight, Your Application and Generic Files</title>
		<link>http://cocoadust.com/2007/03/22/spotlight-your-application-and-generic-files/</link>
		<comments>http://cocoadust.com/2007/03/22/spotlight-your-application-and-generic-files/#comments</comments>
		<pubDate>Thu, 22 Mar 2007 21:36:01 +0000</pubDate>
		<dc:creator>Steve Harris</dc:creator>
				<category><![CDATA[Spotlight]]></category>

		<guid isPermaLink="false">http://cocoadust.com/2007/03/22/spotlight-your-application-and-generic-files/</guid>
		<description><![CDATA[One thing that particularly interests me with Spotlight is how an application like my own Keep It Together can set additional metadata attributes on files owned by generic or other applications&#8217; Spotlight importers.
KIT keeps all the original files on disk, not in a database or file package, so they can be found by Spotlight and [...]]]></description>
			<content:encoded><![CDATA[<p>One thing that particularly interests me with Spotlight is how an application like my own <a href="http://reinventedsoftware.com/kit/">Keep It Together</a> can set additional metadata attributes on files owned by generic or other applications&#8217; Spotlight importers.</p>
<p>KIT keeps all the original files on disk, not in a database or file package, so they can be found by Spotlight and indexed by the relevant importers. What&#8217;s missing right now is the extra metadata from KIT itself &#8211; rating, tags, etc, that isn&#8217;t stored in the actual files.</p>
<p>iPhoto works in a similar way, so it&#8217;s a good case study. Metadata in the image files in iPhoto&#8217;s library will be indexed using the generic Image importer. iPhoto adds some attributes of its own, such as a rating and keywords. Looking at iPhoto&#8217;s importer, it only works on .ipspot files. iPhoto writes out a single iPhoto.ipspot file, which has one line pointing to the XML library that changed.</p>
<p>At first, I wasn&#8217;t sure how the importer could handle that, since a number of different items can be changed in one operation, yet the importer can only return details for a single item, namely the file that triggered the change.</p>
<p>I did some digging and it seems the iPhoto importer doesn&#8217;t return details for the .ipspot file at all, but rather writes out the file to trigger the importer, which manually sets metadata attributes on the files in its library using a private function, MDItemSetAttributes. Looking at the Metadata framework, there&#8217;s also a corresponding MDItemSetAttribute function, also private.</p>
<pre>Boolean MDItemSetAttributes (MDItemRef item, CFDictionaryRef dict);
Boolean MDItemSetAttribute (MDItemRef item, CFStringRef name, CFTypeRef attribute);</pre>
<p>Caution would be wise with that approach because, private function aside, performance is a crucial factor. The importer needs to do its work quickly as it will be called every time the trigger file is changed.</p>
<p>Another thought is that you could actually use these functions in your application, rather than rely on an importer to do the work for you, but as the function is undocumented, there is no way of knowing whether that would also cause issues.</p>
<p>The missing piece of the jigsaw here is how iPhoto opens and selects the image whenever the file is chosen from Spotlight&#8217;s results, since opening the file in the Finder would normally open its default application, such as Preview, Photoshop, or whatever. That&#8217;s not something I&#8217;d want to do for KIT, but it would be interesting to find out how it&#8217;s done. If anyone knows, please comment.</p>
<p><small><b>Update:</b> My understanding now is that selecting the photos in iPhoto as mentioned above is something entirely hardcoded into Spotlight and not something possible for just any app. See the AppleScript statements in /System/Library/CoreServices/Search.bundle/Contents/Resources/iPhotoScripts.plist</small></p>
]]></content:encoded>
			<wfw:commentRss>http://cocoadust.com/2007/03/22/spotlight-your-application-and-generic-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spotlight and Database Files</title>
		<link>http://cocoadust.com/2007/03/18/spotlight-and-database-files/</link>
		<comments>http://cocoadust.com/2007/03/18/spotlight-and-database-files/#comments</comments>
		<pubDate>Sun, 18 Mar 2007 11:24:03 +0000</pubDate>
		<dc:creator>Steve Harris</dc:creator>
				<category><![CDATA[Mac Development]]></category>
		<category><![CDATA[Spotlight]]></category>

		<guid isPermaLink="false">http://cocoadust.com/2007/03/18/spotlight-and-database-files/</guid>
		<description><![CDATA[One of the interesting things about Spotlight is that it only works on individual files. When it sees that a file has changed on disk, it uses the relevant importer to update the metadata store. 
For each time it is called, a Spotlight importer can only provide data for a single item that will be [...]]]></description>
			<content:encoded><![CDATA[<p>One of the interesting things about Spotlight is that it only works on individual files. When it sees that a file has changed on disk, it uses the relevant importer to update the metadata store. </p>
<p>For each time it is called, a Spotlight importer can only provide data for a single item that will be shown in Spotlight&#8217;s results. A different approach is required for multiple items, such as bookmarks in your web browser or iCal events, that are contained in a database or single file (including file packages, because Spotlight won&#8217;t index the files inside).</p>
<p>It&#8217;s a very simple workaround, but seems a little clumsy, considering. Every time such an item is changed, you need to change a file on disk that can trigger Spotlight to invoke the appropriate importer. </p>
<p>To use iCal as an example, in ~/Library/Caches/Metadata, you&#8217;ll see a number of folders for different applications, including iCal itself. Looking in that folder, you&#8217;ll see a number of other folders with UUID-style file names that refer to the calendars in the application, and in those folders various files with .icalevent or .icaltodo extensions. These files contain data that the iCal importer will use to provide metadata to Spotlight. It&#8217;s iCal&#8217;s responsibility to ensure those files are created, updated and deleted as necessary.</p>
<p>In some cases, looking at files in the Metadata folder can reveal an surprising amount of duplicate data, with files filled with text. This is probably because it would be too much of an overhead, or too difficult for the importer to extract the actual data from the database.</p>
<p>If you&#8217;re designing a new application that uses a database or single-file format to contain multiple items that you want indexed by Spotlight, you should bear this in mind.</p>
]]></content:encoded>
			<wfw:commentRss>http://cocoadust.com/2007/03/18/spotlight-and-database-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
