Sunday, September 14, 2014

A Fascinating Feature of Swift

I was just re-reading the swift book, The Swift Programming Language, and came across a feature that I overlooked the first time.

You can define a collection whose type is a protocol type.  This collection can include a bunch of objects of different types that all conform to a single protocol.  

Why is this useful?  When working with values whose type is a protocol type, methods and properties outside the protocol definition are not available.  This allows you to have a collection of different objects, but narrowly define the set of operations on that collection through the protocol type of the collection.  What a great way to create a particular perspective on a collection of different objects.

I can use the protocol to encapsulate the reasons I brought these different objects together, preventing unintended access to methods and properties outside the scope of why I brought these objects together.  This has great security benefits.  While we usually think of protocols as a way to extend objects, we can also use protocols to define a subset of existing capabilities of a set of objects.

Swift is a huge language and it continues to grow.  But even with the current features, there are further depths to explore.

Wednesday, September 3, 2014

Apple to Introduce Updated Hardware and New Product Categories on 9.9.14

At the moment, Xcode 6 Beta 7 has just been released.  We are less than a week from Apple's announcement of new hardware this Fall (Apple teaser: "Wish we could say more").  iOS 8 has been stuck at Beta 5 for a month.  My guess is that Apple may be ahead of the game on iOS 8 and are holding off releasing another beta because of support for unannounced hardware and features in the latest builds they don't wish to become public until the announcement on 9.9.14.

People are always trying to find hidden meanings from the teasers on the announcement invites.  I warrant this one is just a tongue-in-cheek reference to all the times Tim Cook avoided the "what's coming next" question.  Apple will be saying plenty come 9.9.14.