<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/">
 	<channel>
		<title>Blog | Mike Abdullah</title>
		<link>http://www.mikeabdullah.net/</link>
		<description></description>
		<language>en-GB</language>
		<lastBuildDate>Tue, 01 May 2012 23:50:11 +0100</lastBuildDate>
		<docs>http://blogs.law.harvard.edu/tech/rss</docs>
		<generator>Sandvox 2.5.5rc2</generator>
		<item>
			<title>Another Base64 encoding option on the Mac</title>
			<link>http://www.mikeabdullah.net/base64-encoding-sasl.html</link>
			<description>
				&lt;div class="article-summary"&gt;&lt;p&gt;Here's a handy technical tidbit, something that &lt;a href="https://twitter.com/danwood"&gt;Dan&lt;/a&gt; discovered when trying to simplify some of the code we built back when we were getting Sandvox ready for the Mac App Store.&lt;/p&gt;&lt;p&gt;We needed an implementation of Base64 encoding and decoding. Foundation &lt;em&gt;still&lt;/em&gt; doesn't have a public API after all these years (you should of course file a radar, &lt;a href="http://www.openradar.me/9896929"&gt;duping Cédric Luthi's&lt;/a&gt;). We had been using an implementation in one of the libraries that we were trying to avoid linking to.  So Dan did some grepping through various libraries, and found that SASL has an implementation of Base64!&lt;/p&gt;
&lt;p&gt;So we just wrapped some simple implementations around these C-based functions:&lt;/p&gt;

	&lt;div class="first graphic-container wide center"&gt;
		&lt;div style="" class="graphic"&gt;
			&lt;div class="figure-content"&gt;&lt;!-- uk.co.danieltull.Gist --&gt;&lt;a href="https://gist.github.com/2481732"&gt;gist: 2481732&lt;/a&gt;&lt;!-- /uk.co.danieltull.Gist --&gt;&lt;/div&gt;
		&lt;/div&gt;
	&lt;/div&gt;&lt;p&gt;Of course, your project will need to link to libsasl2.dylib. Note that this probably isn't doable on iOS.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Alternatives&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Since &lt;a href="https://twitter.com/#!/mikeabdullah/status/196190524087091200"&gt;publicising this on Twitter&lt;/a&gt;, a variety of people have mentioned their own preferences. So here's a quick list:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;The first post I remember reading on the subject: Matt Gallagher's &lt;a href="http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html"&gt;self-contained code&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Dave Dribin created dedicated encoder and decoder classes; here are &lt;a href="https://bitbucket.org/ddribin/ddfoundation/src/d41050234d53/tests/DDBase64EncoderTest.m"&gt;the tests&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Simon Thulbourn went to the trouble of &lt;a href="https://github.com/sthulbourn/STAdditions/tree/master/STAdditions"&gt;porting PHP's methods&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Peter Hosey &lt;a href="https://twitter.com/#!/boredzo/status/196227848388874241"&gt;points out&lt;/a&gt; that Lion provides this functionality via the &lt;a href="https://developer.apple.com/library/mac/#documentation/System/Reference/SecTransform_header_reference/Reference/reference.html"&gt;SecTransform&lt;/a&gt; APIs&lt;/li&gt;&lt;li&gt;Daniel Jalkut is using Dave Winer's &lt;a href="http://scripting.com/midas/base64/source.html"&gt;old code&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Cédric Luthi is coercing property list serialisation into &lt;a href="https://gist.github.com/1901535"&gt;doing it for him&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Know any others? &lt;a href="https://twitter.com/mikeabdullah"&gt;@message me&lt;/a&gt; or use my &lt;a href="~PAGEID~144"&gt;contact form&lt;/a&gt;&lt;/p&gt;

&lt;/div&gt;
			</description>
			<pubDate>Tue, 24 Apr 2012 10:47:45 +0100</pubDate>
			<guid>http://www.mikeabdullah.net/base64-encoding-sasl.html</guid>
            
			
		</item>
		<item>
			<title>Inequality in equality testing</title>
			<link>http://www.mikeabdullah.net/inequality-in-equality.html</link>
			<description>
				&lt;div class="article-summary"&gt;&lt;p&gt;Do this:&lt;/p&gt;

	&lt;div class="first graphic-container wide center"&gt;
		&lt;div style="" class="graphic"&gt;
			&lt;div class="figure-content"&gt;&lt;!-- uk.co.danieltull.Gist --&gt;&lt;a href="https://gist.github.com/2480081"&gt;gist: 2480081&lt;/a&gt;&lt;!-- /uk.co.danieltull.Gist --&gt;&lt;/div&gt;
		&lt;/div&gt;
	&lt;/div&gt;&lt;p&gt;and you’ll get back NO as the answer. So far, so sensible.&lt;/p&gt;&lt;p&gt;Now do this:&lt;/p&gt;

	&lt;div class="not-first-item graphic-container wide center"&gt;
		&lt;div style="" class="graphic"&gt;
			&lt;div class="figure-content"&gt;&lt;!-- uk.co.danieltull.Gist --&gt;&lt;a href="https://gist.github.com/2480093"&gt;gist: 2480093&lt;/a&gt;&lt;!-- /uk.co.danieltull.Gist --&gt;&lt;/div&gt;
		&lt;/div&gt;
	&lt;/div&gt;&lt;p&gt;Congratulations! You just earnt yourself an exception.&lt;/p&gt;&lt;p&gt;This inconsistency between classes seems rather weird. Why don’t they behave the same? I’d argue that nil should be accepted by both, so that phrasing the test the other way round performs the same:&lt;/p&gt;

	&lt;div class="not-first-item graphic-container wide center"&gt;
		&lt;div style="" class="graphic"&gt;
			&lt;div class="figure-content"&gt;&lt;!-- uk.co.danieltull.Gist --&gt;&lt;a href="https://gist.github.com/2480126"&gt;gist: 2480126&lt;/a&gt;&lt;!-- /uk.co.danieltull.Gist --&gt;&lt;/div&gt;
		&lt;/div&gt;
	&lt;/div&gt;&lt;p&gt;Both of the above cheerfully return you NO, since that’s what sending a (BOOL-returning) message to nil always gives. Wouldn’t it be nice if all four of these examples worked the same way?&lt;/p&gt;&lt;p&gt;Sadly, I think the chances of Apple changing Foundation’s behaviour after all this time are rather slim — let alone the headaches of remembering not to use it when targeting existing OSs. Particularly when I combed the docs and found this &lt;a href="http://developer.apple.com/library/ios/#documentation/General/Conceptual/CocoaEncyclopedia/Introspection/Introspection.html"&gt;nugget&lt;/a&gt;:&lt;/p&gt;
	&lt;div class="not-first-item blockquote-container wide center"&gt;
		&lt;div style="" class="graphic"&gt;

			&lt;blockquote class="figure-content"&gt;
				&lt;p&gt;In all isEqualToType: methods of the Cocoa frameworks, nil is not a valid parameter and implementations of these methods may raise an exception upon receiving a nil. However, for backward compatibility, isEqual: methods of the Cocoa frameworks do accept nil, returning NO.&lt;/p&gt;

			&lt;/blockquote&gt;&lt;/div&gt;
	&lt;/div&gt;&lt;p&gt;So it seems that NSString is the one at fault here. Time to start replacing your calls to ‑isEqualToString: with ‑isEqual: instead? Well, probably not worth it, as, again, Apple are unlikely to pull the rug out from under you on this. But if you decide to, it fortunately seems that ‑isEqual: is &lt;a href="http://weblog.bignerdranch.com/?p=334"&gt;basically as fast&lt;/a&gt; anyway.&lt;/p&gt;

&lt;/div&gt;
			</description>
			<pubDate>Mon, 23 Apr 2012 23:41:11 +0100</pubDate>
			<guid>http://www.mikeabdullah.net/inequality-in-equality.html</guid>
            
			
		</item>
		<item>
			<title>Use non-breaking hyphens when writing about Objective-C methods</title>
			<link>http://www.mikeabdullah.net/non-breaking-hyphen-for-method-names.html</link>
			<description>
				&lt;div class="article-summary"&gt;&lt;p&gt;As you may have noticed, I blog about code rather a lot, often including method names inline, ‑justLikeThis. An annoynance with doing that is the risk that a web browser might split the method straight after the hyphen, making it awkward to read. Many of you will be thinking the solution is dead obvious, and indeed it is if you know it exists: use non-breaking hyphens instead of regular ones.&lt;/p&gt;&lt;p&gt;On OS X, this can be easily found from the Characters Palette (Edit &amp;gt; Special Characters… in most apps). I've added the non-breaking hyphen to my favourites for good measure.&lt;/p&gt;&lt;/div&gt;
			</description>
			<pubDate>Fri, 20 Apr 2012 13:58:05 +0100</pubDate>
			<guid>http://www.mikeabdullah.net/non-breaking-hyphen-for-method-names.html</guid>
            
			
		</item>
		<item>
			<title>Understanding -[NSArrayController add:]</title>
			<link>http://www.mikeabdullah.net/nsarraycontroller-add.html</link>
			<description>
				&lt;div class="article-summary"&gt;&lt;p&gt;A fairly common question on the &lt;a href="https://lists.apple.com/mailman/listinfo/cocoa-dev"&gt;Cocoa-dev mailing list&lt;/a&gt;, is how to know when ‑[&lt;a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSArrayController_Class/Reference/Reference.html"&gt;NSArrayController&lt;/a&gt; add:] has finished doing its work. The simple is answer is: you can’t. The docs state:&lt;/p&gt;

	&lt;div class="first blockquote-container wide center"&gt;
		&lt;div style="" class="graphic"&gt;

			&lt;blockquote class="figure-content"&gt;
				&lt;p&gt;&lt;strong&gt;Special Considerations&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Beginning with Mac OS X v10.4 the result of this method is deferred until the next iteration of the runloop so that the error presentation mechanism (see Error Responders and Error Recovery) can provide feedback as a sheet.&lt;/p&gt;

			&lt;/blockquote&gt;&lt;/div&gt;
	&lt;/div&gt;&lt;p&gt;Talk of “the result of this method” kinda implies there’s some sort of callback available, but there isn’t. To my understanding, if you really want to deal with this, your only choice is to effectively re-implement -add: yourself. Fortunately I’ve done this for you:&lt;/p&gt;

	&lt;div class="not-first-item graphic-container wide center"&gt;
		&lt;div style="" class="graphic"&gt;
			&lt;div class="figure-content"&gt;&lt;!-- uk.co.danieltull.Gist --&gt;&lt;a href="https://gist.github.com/2367295"&gt;gist: 2367295&lt;/a&gt;&lt;!-- /uk.co.danieltull.Gist --&gt;&lt;/div&gt;
		&lt;/div&gt;
	&lt;/div&gt;&lt;p&gt;Looking at this, I think it becomes understandable why -add:’s result is deferred. If &lt;a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Protocols/NSEditor_Protocol/Reference/Reference.html"&gt;committing editing&lt;/a&gt; happens to fail, then Cocoa will present that error as a sheet. The delegate is only called once that alert has been dismissed. This does raise the question (rdar://11270645) though of how Apple’s implementation handles such failures. Does it go ahead and add a new object anyway? Are the pending changes &lt;a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Protocols/NSEditor_Protocol/Reference/Reference.html"&gt;discarded&lt;/a&gt;? Or perhaps it bails out, hopefully at least beeping to indicate the failure.&lt;/p&gt;&lt;p&gt;Cocoa has a rather odd design for sheet-handling whereby you cannot immediately present one after another without calling &lt;a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSWindow_Class/Reference/Reference.html"&gt;-orderOut:&lt;/a&gt; on the first. Alternatively, you can put off presenting the sheet until the next spin of the runloop. It seems from the docs that NSArrayController anticipates such a scenario by delaying its call to commit editing, just in case a sheet does need to be presented. I’ve assumed that you’re in control of your code enough to order out a previous sheet manually if needed, and so left it out of the code.&lt;/p&gt;&lt;p&gt;I think the only other thing worth noting is that you can’t quite apply this same code as an extension to &lt;a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSTreeController_Class/Reference/Reference.html"&gt;NSTreeController&lt;/a&gt;, since its -newObject method doesn’t have the smarts to deal with creating managed objects. You’d need to override -newObject yourself too, or provide equivalent logic inside of -addWithCompletionHandler:&lt;/p&gt;

&lt;/div&gt;
			</description>
			<pubDate>Wed, 18 Apr 2012 08:30:35 +0100</pubDate>
			<guid>http://www.mikeabdullah.net/nsarraycontroller-add.html</guid>
            
			
		</item>
		<item>
			<title>New template</title>
			<link>http://www.mikeabdullah.net/new-template.html</link>
			<description>
				&lt;div class="article-summary"&gt;&lt;p&gt;I fancied a change. So there.&lt;/p&gt;&lt;/div&gt;
			</description>
			<pubDate>Tue, 17 Apr 2012 18:28:36 +0100</pubDate>
			<guid>http://www.mikeabdullah.net/new-template.html</guid>
            
			
		</item>
		<item>
			<title>An -awakeFromInsert gotcha</title>
			<link>http://www.mikeabdullah.net/an--awakefrominsert-gotcha.html</link>
			<description>
				&lt;div class="article-summary"&gt;&lt;p&gt;Imagine you’ve got a Core Data model where an entity has a one-to-one relationship with another. Say, “ObjectA” and its “Partner”. You expect a pair of these objects to be hooked up at all times. So you make life easy for yourself and create the partner automatically:&lt;/p&gt;

	&lt;div class="first graphic-container wide center"&gt;
		&lt;div style="" class="graphic"&gt;
			&lt;div class="figure-content"&gt;&lt;!-- uk.co.danieltull.Gist --&gt;&lt;a href="https://gist.github.com/2217400"&gt;gist: 2217400&lt;/a&gt;&lt;!-- /uk.co.danieltull.Gist --&gt;&lt;/div&gt;
		&lt;/div&gt;
	&lt;/div&gt;&lt;p&gt;Well, &lt;strong&gt;don’t&lt;/strong&gt; do this!&lt;/p&gt;&lt;p&gt;If you’re looking at using the new parent/child contexts feature in Core Data, the shortcut above will seriously trip you up. What the &lt;a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/CoreDataFramework/Classes/NSManagedObject_Class/Reference/NSManagedObject.html%23//apple_ref/doc/uid/TP30001171-235678"&gt;docs&lt;/a&gt; don’t mention is that when saving a child context, the process goes something like this:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Copies of any new objects from the child context are inserted into the parent context. They share the same ID, but are two different objects (as you’d expect!), one for each context&lt;/li&gt;&lt;li&gt;The insertion calls -awakeFromInsert to be called on the new objects in the parent context&lt;/li&gt;&lt;li&gt;Attributes and relationships are applied to the objects in the parent context so that they match the child context&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;If your custom -awakeFromInsert method happens to insert objects of its own, as in the example above, that code is going to run for a second time and create an extra object that is about to be orphaned by step 3. Depending on your  model’s validation rules, you’ll then see this show up as either the parent context failing to save, or mysterious extra objects appearing!&lt;/p&gt;&lt;p&gt;The docs do state:&lt;/p&gt;

	&lt;div class="not-first-item blockquote-container wide center"&gt;
		&lt;div style="" class="graphic"&gt;

			&lt;blockquote class="figure-content"&gt;
				&lt;p&gt;If you want to set attribute values in an implementation of this method, you should typically use primitive accessor methods&lt;/p&gt;

			&lt;/blockquote&gt;&lt;/div&gt;
	&lt;/div&gt;&lt;p&gt;I’m inclined to read between the lines and reason thusly:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Setting up a relationship using the primitive setter method is no good since Core Data won’t maintain the inverse of the relationship&lt;/li&gt;&lt;li&gt;So I should use the proper setter method instead&lt;/li&gt;&lt;li&gt;But the docs tell me to use primitive setters in -awakeFromInsert (albeit for attributes)&lt;/li&gt;&lt;li&gt;So maybe I better just not do anything involving relationships there&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;On the other hand, the &lt;a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdManagedObjects.html"&gt;Core Data Programming Guide&lt;/a&gt; does have this to say:&lt;/p&gt;

	&lt;div class="not-first-item blockquote-container wide center"&gt;
		&lt;div style="" class="graphic"&gt;

			&lt;blockquote class="figure-content"&gt;
				&lt;p&gt;Change processing is explicitly disabled around awakeFromFetch so that you can conveniently use public set accessor methods without dirtying the object or its context. This does mean, however, that you should not manipulate relationships, as changes will not be properly propagated to the destination object or objects. Instead, you can override awakeFromInsert&lt;/p&gt;

			&lt;/blockquote&gt;&lt;/div&gt;
	&lt;/div&gt;&lt;p&gt;So that does seem to suggest that working with relationships from -awakeFromInsert is OK! Who to trust? I don’t know. Just make sure my example doesn’t bite you. And yes, I filed rdar://11119484 asking for the docs to mention this.&lt;/p&gt;

&lt;/div&gt;
			</description>
			<pubDate>Tue, 27 Mar 2012 16:40:02 +0100</pubDate>
			<guid>http://www.mikeabdullah.net/an--awakefrominsert-gotcha.html</guid>
            
			
		</item>
		<item>
			<title>An NSError error</title>
			<link>http://www.mikeabdullah.net/an-nserror-error.html</link>
			<description>
				&lt;div class="article-summary"&gt;&lt;p&gt;I was originally going to remind people to check their error handling code is doing the right thing (I recently found some problems in our &lt;a href="https://github.com/karelia/imedia"&gt;iMedia framework&lt;/a&gt; of this nature), but &lt;a href="http://weblog.bignerdranch.com/?p=360"&gt;Big Nerd Ranch saved me the effort&lt;/a&gt;. So instead you got “&lt;a href="~PAGEID~4D188E69F391431493E0"&gt;Passing errors across threads using blocks&lt;/a&gt;”. Hey, two articles for the price of one. Awesome!&lt;/p&gt;&lt;/div&gt;
			</description>
			<pubDate>Mon, 26 Mar 2012 20:46:46 +0100</pubDate>
			<guid>http://www.mikeabdullah.net/an-nserror-error.html</guid>
            
			
		</item>
		<item>
			<title>Passing errors across threads using blocks</title>
			<link>http://www.mikeabdullah.net/cross-thread-error-passing.html</link>
			<description>
				&lt;div class="article-summary"&gt;&lt;p&gt;In these strange times of blocks and concurrency-patterned managed-object-contexts (I swear I saw one once, but it flew off before I could grab my camera), it’s not uncommon to be calling methods across thread boundaries and needing to return an error object as a result. Here’s a simple example:&lt;/p&gt;

	&lt;div class="first graphic-container wide center"&gt;
		&lt;div style="" class="graphic"&gt;
			&lt;div class="figure-content"&gt;&lt;!-- uk.co.danieltull.Gist --&gt;&lt;a href="https://gist.github.com/2206650"&gt;gist: 2206650&lt;/a&gt;&lt;!-- /uk.co.danieltull.Gist --&gt;&lt;/div&gt;
		&lt;/div&gt;
	&lt;/div&gt;&lt;p&gt;So what’s wrong here? If saving &lt;em&gt;fails&lt;/em&gt;, it will return by reference an NSError object encapsulating why, stored into the error pointer. In all likelihood, that error is autoreleased, due to be deallocated when the current pool drains. When will it drain? Well, potentially, -performBlockAndWait: runs on a different thread to the caller. And if so, that will likely drain the autorelease pool when that chunk of work completes. Quite possibly before the caller of our code is finished dealing with the error!&lt;/p&gt;&lt;p&gt;Normally blocks retain objects as needed for you, but because the error is passed around by reference, we have no such luxury. Instead, here’s the solution:&lt;/p&gt;
	&lt;div class="not-first-item graphic-container wide center"&gt;
		&lt;div style="" class="graphic"&gt;
			&lt;div class="figure-content"&gt;&lt;!-- uk.co.danieltull.Gist --&gt;&lt;a href="https://gist.github.com/2209110"&gt;gist: 2209110&lt;/a&gt;&lt;!-- /uk.co.danieltull.Gist --&gt;&lt;/div&gt;
		&lt;/div&gt;
	&lt;/div&gt;&lt;p&gt;This ensures that the error object is kept alive for as long as the calling thread needs it.&lt;/p&gt;

&lt;/div&gt;
			</description>
			<pubDate>Mon, 26 Mar 2012 18:09:06 +0100</pubDate>
			<guid>http://www.mikeabdullah.net/cross-thread-error-passing.html</guid>
            
			
		</item>
		<item>
			<title>Migrating from alias handles to bookmark data</title>
			<link>http://www.mikeabdullah.net/migrating-from-alias-handle.html</link>
			<description>
				&lt;div class="article-summary"&gt;&lt;p&gt;OS X 10.6 Snow Leopard introduced a wealth of new APIs on &lt;a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/Reference/Reference.html"&gt;NSURL&lt;/a&gt;. In particular, a set of methods for dealing with bookmark data.&lt;/p&gt;&lt;p&gt;A great many developers, &lt;a href="http://karelia.com/"&gt;Karelia&lt;/a&gt; included, have a need to keep references to files that might be moved to a new location by the user. Prior to 10.6, the best way to accomplish this was by using the old Carbon &lt;a href="https://developer.apple.com/library/mac/#documentation/Carbon/Reference/Alias_Manager/Reference/reference.html"&gt;Alias Manager&lt;/a&gt; to create alias records, and then store the record’s data.&lt;/p&gt;&lt;p&gt;Snowy supersedes those APIs with native Cocoa &lt;a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/Reference/Reference.html"&gt;methods on NSURL&lt;/a&gt;. They’re pretty straightforward and match up pretty closely to the old alias record concepts:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;The &lt;span style="font-family: 'Andale Mono'; "&gt;bookmarkData…&lt;/span&gt; methods take a URL or alias file and create bookmark data from it. You can then persist that data as your app sees fit&lt;/li&gt;&lt;li&gt;&lt;span style="font-family: 'Andale Mono'; "&gt;+URLByResolvingBookmarkData:…&lt;/span&gt; performs the reverse, locating the best match for the file on disk (there’s an equivalent &lt;span style="font-family: 'Andale Mono'; "&gt;-init&lt;/span&gt; method too)&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Various &lt;a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/Reference/Reference.html"&gt;options&lt;/a&gt; enums can be passed in to adjust quite how these methods operate. As well as the API reference, Apple have a &lt;a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/Reference/Reference.html"&gt;guide document&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;Do you have existing alias record data that needs bringing into the new world? (This includes the popular &lt;a href="https://github.com/nathanday/ndalias"&gt;NDAlias&lt;/a&gt; and &lt;a href="https://github.com/rentzsch/bdalias"&gt;BDAlias&lt;/a&gt; wrappers). You might imagine “bookmark data” is just Cocoa’s terminology for a wrapper around the old APIs, but that’s not the case.&lt;/p&gt;&lt;p&gt;Bookmarks use their own custom format (I assume Apple has good reason for this) that’s incompatible with the alias manager. Conversion is one-way and you have to drop down to CoreFoundation: &lt;span style="font-family: 'Andale Mono'; "&gt;&lt;a href="https://developer.apple.com/library/mac/#documentation/CoreFoundation/Reference/CFURLRef/Reference/reference.html%23//apple_ref/c/tdef/CFURLRef"&gt;CFURLCreateBookmarkDataFromAliasRecord&lt;/a&gt;&lt;/span&gt;.&lt;/p&gt;&lt;p&gt;Now is the time to look at adopting these APIs, since OS X 10.7.3 introduces an extension to the bookmark format: &lt;a href="https://developer.apple.com/library/mac/#documentation/Miscellaneous/Reference/EntitlementKeyReference/EnablingAppSandbox/EnablingAppSandbox.html%23//apple_ref/doc/uid/TP40011195-CH4-SW1"&gt;security-scoped bookmarks&lt;/a&gt;. NSURL has new &lt;a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/Reference/Reference.html"&gt;options and methods&lt;/a&gt; to accommodate this. There’s a good chance your app will want to adopt these for when/if sandboxing rules come into effect for the app store. &lt;/p&gt;&lt;/div&gt;
			</description>
			<pubDate>Tue, 21 Feb 2012 16:11:32 +0000</pubDate>
			<guid>http://www.mikeabdullah.net/migrating-from-alias-handle.html</guid>
            
			
		</item>
		<item>
			<title>Why I worry that demanding permission before accessing contact data is too crude</title>
			<link>http://www.mikeabdullah.net/address-book-entitlements.html</link>
			<description>
				&lt;div class="article-summary"&gt;&lt;p&gt;&lt;a href="http://allthingsd.com/20120215/apple-app-access-to-contact-data-will-require-explicit-user-permission/"&gt;Apple have said&lt;/a&gt; that they will soon be updating iOS to check for explicit permission before an app can have access to contact data.&lt;/p&gt;&lt;p&gt;Consider an app like &lt;a href="http://sandvox.com/"&gt;Sandvox&lt;/a&gt;. Yes, it doesn’t ship on iOS, and Apple haven’t announced if the Mac will be receiving the same treatment, but there are plenty of legitimate reasons like ours to use the address book API on iOS. So:&lt;/p&gt;&lt;p&gt;When you create a new document/site in Sandvox, we look up your “Me” card in order to pre-populate the site’s title and footer. It’s a nice touch that makes the new site instantly feel more &lt;em&gt;yours&lt;/em&gt;. Under the scheme Apple is proposing, this access would first require you to grant Sandvox permission to access your address book. It seems to me that at this point there’s then a variety of possible reactions:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Annoyance/fear: “Why I am I being bugged for this? What is the app going to do with my info?” — made even worse if the info turns out to be irrelevant to the site!&lt;/li&gt;&lt;li&gt;“I have no idea what this is for; I’ll just say OK like I do to all alerts” — pretty common (if bad) behaviour that we’d be serving to reinforce&lt;/li&gt;&lt;li&gt;“I have no idea what this is for; I don’t want to grant access” — we’ve now bugged the user to no gain&lt;/li&gt;&lt;li&gt;“Hopefully this is for something smart and innocuous, I’ll say yes”&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Consider me sceptical, but I think the last of these is going to be fairly rare! It seems at this point the tiny gain of this Sandvox nicety would be outweighed by all the possible ways to annoy/confuse/upset customers.&lt;/p&gt;&lt;p&gt;Of course I suppose Apple could add some new API that lets us tell the user &lt;em&gt;why&lt;/em&gt; access is requested. That seems a potential trojan nightmare though; the alert could be a complete lie! In theory the app store reviewers should be able to catch such behaviour — perhaps this API would only be available to app store apps?&lt;/p&gt;&lt;p&gt;When sandboxing starts being widely adopted, we have the beginnings of a solution to this for app store apps. Without the address book entitlement, apps are unable to use the entire API. It becomes a lot harder to sneak through an app that access the data in an inconspicuous way. But that won’t stop apps with a legitimate use for the data from abusing it, such as uploading to a server to keep.&lt;/p&gt;&lt;p&gt;Perhaps there could be two or more tiers of entitlement? This Sandvox feature only needs access to the “Me” card and a few fields. Apps like Path could have a different entitlement for access to hashed data only.&lt;/p&gt;&lt;p&gt;Who knows really? We’ll just have to wait and see what the future brings.&lt;/p&gt;&lt;/div&gt;
			</description>
			<pubDate>Thu, 16 Feb 2012 23:58:39 +0000</pubDate>
			<guid>http://www.mikeabdullah.net/address-book-entitlements.html</guid>
            
			
		</item>
 	</channel>
</rss>

