Archive for May, 2015

Swift: Hacking APIs

tsmc001

Last evening a colleague asked whether it was possible to test private APIs in Swift playgrounds. Answer? Sort of.

Swift is not, as you will probably be unshocked to learn, not particularly friendly to API hacking. Playgrounds make it worth the bother by offering a perfect fit for exploration, testing, and prototyping.

Here’s what you do.

Read On…

Blast from the past: All I want for WWDC is…nothing

CCj7O_1VIAAa3fQ

Logo has been fixed by  Radek Pietruszewski ‏@radexp        

 

From February 2014: original post

February may seem early to you to be strategizing about Apple WWDC announcements. For tech writers, it’s crunch time. To plan books, posts, and other coverage, you try to anticipate how big a change is coming up and what areas will be affected.

For example, Victor was asking me the other day what I’d like to see in the next installments of iOS and OS X. My answer is the same as it’s been for years: “Bug fixes and security enhancements.” I’m a bit over the yearly update cycle.

Read On…

Swift: Indices

pointing-hand-1138681-m

In Objective-C, ranges are portable things. NSRange consists of a simple integer position and length and can be used with any object that supports integer-based indexing.

 typedef struct _NSRange {
      NSUInteger location;
      NSUInteger length;
} NSRange;

Read On…

Swift: Don’t do that

bad-hair-day---alpaca-1395419-m

The assorted list:

Don’t add code cruft. Avoid parentheses around conditions in if-statements or with the return keyword. Don’t add semicolons except where syntactically demanded in statements or to separate statements on the same line. (Do skip parens, semicolons, other relics of ObjC life)

Read On…

Swift: Using functions to initialize View types

playground-in-blue-and-orange-1443644-m

I spend a lot of time working in playgrounds. Playgrounds are fast and focused, allowing me to rapidly prototype Swift code. I use the OS X version more than I ever expected, even when my actual coding destination is iOS. OS X playgrounds run natively and support cross-platform solutions for technologies like SpriteKit, AVFoundation, and Core Image. Importantly, you can add interactive controls like sliders to your OS X playgrounds using nibs, so you can explore outcomes more flexibly, skipping many edit/compile/run tasks.

Read On…