sohail.io

  • About

Archives for June 2015

Swift Memory Management Exercise

June 21, 2015

I’ve covered my approach to learning Swift in an earlier post.

In this post, I wanted to post my solution to an exercise in the Intermediate Swift Tutorial Series video for Memory Management (Part 9), available at RayWenderlich.com. Note that you’ll need to be a paying subscriber to access the video tutorial page.

The exercise challenges the reader to create an object graph avoiding retain cycles, noting that Swift Array objects, like in many reference counted languages, will have strong references to all of their elements.

You’ll need to review the actual tutorial challenge for context (that’s copyright material I won’t reproduce here). However, if you’ve followed along, you’ll know that the posted solution playground doesn’t actually demonstrate or prove to the reader that there are no retain cycles.

As such, I set out to answer the exercise in a way that would give me that tangible satisfaction that the full object graph had gotten deallocated.

You can access the full contents of my solution playground from this gist.

As you can see below, when I set the rwDevCon variable to nil, it sets off the chain of visible deallocation. 

You can also download a zip archive of the Xcode 7 Beta 1 playground that I used to complete the exercise from the Ray Wenderlich tutorial here: MyLearningPart09.playground.zip

My Solution to the Memory Management Exercise

Filed Under: iOS Tagged With: arrays, memory management, optionals, raywenderlich.com, retain cycles, swift, weak

Learning Swift: My Approach

June 21, 2015

With the announcement of Swift 2.0 at WWDC2015, I’ve finally taken the plunge to set aside a few days and actually learn Swift. I’m not mixing Swift with production Objective-C anytime soon, but I’ve found that code snippets on the web, tutorials and even Apple’s WWDC videos are becoming increasingly difficult to follow (and fully comprehend) without at least knowing the basics of Swift.

On the path to acquiring this knowledge, I’m going through a few resources in parallel.

Book: The Swift Programming Language

Apple’s The Swift Programming Language book throws you into Swift coding in the first chapter (“A Swift Tour”), which is a quick preview through many key aspects of the language. Fear not, the next chapter is the start of the Language Guide, which slows down the pace and covers the concepts in more depth.

I’ve been making my way through the new pre-release version covering Swift 2.0, and using Xcode 7 Beta 1 for all exercises in the book as well as those found in other resources.

Videos: WWDC 2014 and 2015

I’m a completionist, and so given that WWDC sessions often build upon successive years, I started back with the 2014 sessions. Anything with the word “Swift” in the title would get watched. That means beyond just the language itself, I’d cover playgrounds and interoperability with Objective-C.

You can watch Apple’s WWDC2014 and WWDC2015 Swift videos online, or through the WWDC iOS app.

The benefit of starting back at 2014 is that I can see what changed. I know that println used to be a thing, but that now it is just print  This helps me navigate the myriad tutorials and snippets of code online, without being bewildered about what I might have missed. I do believe this will actually save me more time in the long run.

Blog: Apple’s Official Swift Blog

Apple’s Official Swift Blog is a refreshingly candid and helpful peak inside the minds of Swift’s creators and stewards. I’m starting from the beginning, and progressing as the other resources give me the needed foundations to fully appreciate. I stop whenever I get to a post that talks about concepts of Swift I’ve not yet covered elsewhere.

I then revisit when I’ve learned more.

Ray Wenderlich’s Swift Tutorial Video Series

This is where I spend most of my time of late. In addition to the video series, there are some great written articles you’ll find as additional resources.

Here’s where you’ll find the Swift video tutorial series with Brian Moakley that I’m going through presently. Watch each video and then do the exercise(s). Struggle with it. Search through API docs to think about how you would solve various challenges when you need more inspiration.

This is where the learning is really solidifying for me. If I had to pick one resource, it would be this one. But of course, neither you nor I need to take such drastic measures, so supplement with all of the above!

Note that you need to be a paying subscriber to raywenderlich.com to watch these videos. If you develop iOS software for part or all of your income however, this meager subscription fee should be a no brainer. It is extremely cost effective and the material is very well produced.

Whenever I’ve needed to bring on iOS developers to augment an existing project team, I’ve always directed folks to RayWenderlich.com and the excellent iOS by Tutorials series to make sure everyone knows how to use the new APIs each year. It’s important to adopt the new APIs because they build on each other.

Folks who refused to adopt Auto Layout, Size Classes and Adaptive Layout are now going to have a hard time supporting side-by-side multitasking on iPad in iOS9.

As an experienced developer, I look to the resources on RayWenderlich.com to keep up to date. It’s not just for beginners or intermediates. In fact, for very experienced developers, it’s still the fastest way to get up to speed on the new frameworks and APIs.

But I digress! And no, Ray Wenderlich didn’t pay me anything to praise their material!

 

Filed Under: iOS Tagged With: exercise, raywenderlich.com, swift, tutorial

search

Categories

  • General
  • iOS

Recent Posts

  • AppleScript Export to CSV via iWork Numbers
  • Verifying the Status of an Auto-Renewable Subscription
  • Swift Memory Management Exercise
  • Learning Swift: My Approach
  • UIAutomation Command Line Test Runner for Xcode 6

This Blog

My name is Sohail. I'm a developer-consultant and entrepreneur primarily focused on building high quality iOS apps.

I write about software development. Mostly iOS related and sometimes, Ruby on Rails.

See the About page for more bio.

Sohail Ahmed - About page for blog author bio

Category Specific RSS

  • General (2)
  • iOS (6)

Archives

  • October 2015 (2)
  • June 2015 (2)
  • September 2014 (1)
  • October 2013 (3)

Copyright © 2021 Sohail A. · Log in

All opinions expressed are strictly those of the author, and do not necessarily reflect those of guests, partners, sponsors, customers or affiliates.