The swift class extension you’ll want to include in all your projects

Here is one of my favorite extension I created for Array. Very useful shortcut when you use abstraction ( as you should ) and you want to create an array from another one.


Instantiate an Array of type A with an another array of type ( or protocol ) B and fills it with elements from B that can be cast to A.



Screen Shot 2016-06-08 at 2.57.33 PM

You could always use .filter but it would take way more lines.  I often use it to get a specific subview in my view hierarchy.  Here’s the link to the playground file.


That’s it for today folks !  See you soon. MAB.


Leave a Reply

Your email address will not be published. Required fields are marked *