Book Updates now available #swiftlang

Screen Shot 2015-10-27 at 9.32.21 AM

I just pushed a major revision to Swift Documentation Markup and a minor revision to Playground Secrets and Power Tips. These should now be available in iBooks.

I extend feature discussion in the Markup book, added some material mentioned in Apple’s online markup documentation (but not well supported in Xcode), and since Dave Verwer promised playground coverage in last Friday’s iOS Dev Weekly, I introduced a section about that as well. I also added a little coverage about promising third party tools.

There’s about 30% new material, so it’s a substantial bump in content. I’m extending Markup’s initial sale discount on iTunes for another week due to the positive feedback.

Once again, let me express my gratitude to everyone who has been tweeting, posting, and otherwise helping to spread the word about both Markup and Playgrounds. If you’re a blogger with an audience that’s interested in these topics, please ping me by email for a promo code if you’d like to write up a review on your site.

Today, I also got a first look at the galley’s for the Swift Developer’s Cookbook. I’m really excited about this — January seems forever away from October.

I’m back to the writing trenches, for now.


  • You removed the little you had on liveViews. I’ve been trying to get UIView animations to work:

    • The new way of doing it is XCPlaygroundPage.currentPage.liveView, which is discussed in Exploring Playgrounds. There’s several examples in the first section (Playground Power), and a quick hit in the Xcode 7.1 update section

      Just make sure the playground is set for indefinite execution, set the liveView to the view that’s animating, and open the assistant. see:

      • I use the liveView in the SO code, as discussed in the book, but for some reason the flip animation isn’t shown. There used to be a Full Simulator option that was removed. It’s no longer necessary?

        • Btw, my SO doesn’t set the indefinite flag but my actual playground does. Still doesn’t work.

          • The separate full simulator is not part of Xcode 7.x playgrounds. So far, I’ve updated the book for each Xcode update to match the current reality of the tools. (To be clear: the simulator is “there”, but unlike older playgrounds, it’s not run separately. The new system starting in the latest versions of Xcode enables you to set your liveView to either a view *or* a view controller)

  • I got a working example. I had to use an NSTimer to delay the animation. Placed the working code in a SO answer:

    Perhaps you can cover UIView animations in the next book update? Feel free to use anything I did. After all, I started with your book. 🙂

    • Not sure what’s going wrong for you. Seems to work for me: plus there’s really nothing there that’s playground specific beyond the two XCPlayground calls… What would you like to see, keeping in mind this is a book about playgrounds and not about iOS dev?

      • Yeah, I guess it worked for me too once I added the NSTimer. I didn’t know that I needed a delay. My initial flip was 12 seconds so I didn’t think it should finish immediately. You have a delay in your example.

        I’m actually trying to get the two little squares to flip so I can prototype enhancements to my games (see pic on my page: but that’s probably not a playground issue. Thanks for your help.

        • The reason the timer even plays a role is because this isn’t doing the normal UIViewController lifecycle. Normally, when working with UIVC, you need to wait until view will/did appear to animate. I only used a delay because you used a delay. Here’s how you can eliminate the delay entirely:

          Again, this is simple UIKit stuff, so I’m not sure if that really belongs in a playground book. What do you think?

          p.s. This would also be improved by eliminating `go()`, moving that into viewDidAppear, and moving the view construction into `loadView()`. Basically when working with UIKit, using UIKit best practices gets you the best code and best results:

          • Thanks, using the viewDidAppear() is a better solution. I think you should cover this in your book, unless you plan on writing a “Learn iOS Using Playgrounds” beginner book. Playgrounds make a great way to start learning iOS and Swift.

            I’ve started a “Swift Cookbook” using Playgrounds: The beginner audience is probably 100x bigger audience than current programmers who want to learn using Playgrounds. I imagine many intermediate/advanced developers will just Google for solutions. Beginners won’t know where to begin so they’ll buy a book.

  • I have read your updates about Live Views in Xcode 7.1 but I still can’t figure out how to update the Crustacean.playground example from WWDC to use the new protocol. Are there any real code samples anywhere? Speaking of code samples, I was trying to figure out if I could use your book to teach a couple kids using some swift examples but I can’t remember how to access your code samples from iBooks. Is there a way to link to working samples?

    • First thing I did was Edit > Convert > To Latest Swift Syntax. (There were no source changes needed). Then I clicked on the error to see what was up (CGContext not unwrapped). Changed that to:

      guard let context = UIGraphicsGetCurrentContext() else {return}

      Finally, I updated the show view stuff to:

      XCPlaygroundPage.currentPage.liveView = diagramView

      Opened the assistant editor, everything worked:

      • Thanks. I didn’t realize that the diagramView would already conform to the protocol. Somehow the Apple 7.1 documentation described in your chapter notes made it much more confusing than it needed to be in this particular case. I have yet to see a full example implementation of the protocols to make sense of it.

        I do still have a question as to the best way to leverage your book. I wanted to start teaching by having them run some fun examples like those in your Playground Power chapter but don’t know how to access the code. Can you offer some guidance?

        • You access code through the project navigator (View > Navigators > Project Navigators). Click the twiddle-to-expose toggles to the left of each playground component.

          • I apologize. Perhaps I am exceedingly dim. I didn’t think my question was so confusing but let me try to frame it better.

            I am reading your excellent book, Playground Secrets and Power Tips, in iBooks. I am reading the Playground Power chapter. I see the first couple examples. They are just pictures. The first picture shows code. It starts with: “BezierStartShape(8, length: 100, percent: -1.5)”. The second picture shows code starting with: “public struct Card: CustomPlaygroundQuickLookable”.

            My question is, can I access the code for these examples and run the code in an Xcode playground? If so, how do I cross-reference the example with what I see in the picture?

  • Stephen: Left you a couple of new playgrounds at

    • Thank you very much for these extra examples. I was able to figure out that these .zip files contain one or more playgrounds that reflect some of the samples in the book. I had not much prior exposure to “GitHub”. I wonder if anyone else was similarly confused reading “About this Book Github repo:” without any further detailed explanation on how to leverage the material.

      For me, examples are everything to make my understanding complete. For a novice to make use of your book requires some prior exposure to Xcode and knowing what to do with the zip files. Using your book, Xcode, and navigating quickly through examples you’ve got, you could take someone pretty far into demonstrating the power of Swift and Playground programming.

      Though Apple does use Playgrounds in its documentation, the appeal of running graphical examples like your Spiro, CG, and Cards, plus some others that I’ve found that use SceneKit and SpriteKit, are a great way to “reverse-engineer” the teaching of programming concepts by adding and subtracting smaller bits of code.

      Perhaps you have an additional target audience for your book!