Archive for April, 2015

Swift: Playground Book update submitted

Screen Shot 2015-04-05 at 1.58.16 PM

More than twice as long, tons of new coverage, improved interactive-document how-to, and iBooks (!) which should allow updates. The Kindle version will not be updated due to Amazon’s restrictions.

Note: Once it’s approved, ping me by email if you’ve bought a copy and I’ll send you a promo code for iBooks. I can’t generate the codes until it’s been processed.

Current table of contents:

  • Playground Power
  • Creating Playgrounds
  • Controlling Your Workspace
  • Working with the Playground Editor
  • Documenting Playgrounds
  • Playground Internals
  • Building Mini Apps

The book story to date:


Swift: Launch at Login

Was helping someone this morning on IRC while waiting for dr’s apt. He was pretty desperate for a launch-at-login check, so I pulled up my old ObjC version and started poking away at a Swift version, which follows.  (Note: this is 10.10 and later as I didn’t really feel like including pre-10.10 support for a proof of concept.) I had a few interesting revelations along the way, mostly dealing with the fact that you can’t use a lot of CF items directly as they’re unmanaged.

I  doubt I’ve applied the unmanaged-to-value transformations well here as this is the first time I’ve used them. The docs say:

“ The Unmanaged<T> structure provides two methods to convert an unmanaged object to a memory managed object—takeUnretainedValue() and takeRetainedValue(). Both of these methods return the original, unwrapped type of the object. You choose which method to use based on whether the API you are invoking returns an unretained or retained object.”

I suspect I need retained for copy/create and unretained for get but I wish I could apply Project > Analyze and have it tell me whether I’m messing up the memory management here.