Programmer by day, artist by night


MVC Communication Methods

Views use:

  • Outlets – target action
  • Delegates – should, will, did
  • Data Source – data at, count

Models use:

  • Notification & KVO (Key Value Observing)

Additional Notes

The Card struct is UI independent. It’s tempting to allow the Card to also store the emoji symbol. However the emoji symbol is a view element. Therefore it should not be allowed in Card.

Classes get free initializers as long as all their instance variables are initialized.
Struct also get free initializer allowing all its instance variables to be initialized.

Lazy vars cannot have property observers (didSet).

State of the App after Implementing the Code from Lecture 2

Source code

The source code of the app Concentration is available here:

Developing iOS11 Apps with Swfit - Lecture 1 Summary

What’s New

After completing the 1st lecture, here is what I found new from the previous courses I took a few years ago.

  • Uses Swift 4, Xcode 9
  • Rename (refactor) with cmd + click on variable name
  • Fuzzy match on intellisense (was available form Xcode 8)
  • Back to developing card game  (the previous few years focused on developing calculator)
  • Outlet collections


  • Property observers are used to keep the UI in sync with instance variables. For example: var flipCount = 0 { didSet { flipCountLabel.text = “Flips: \(flipCount)” } }

The following video shows the state of the app Concentration after completing lecture 1.


The course Developing iOS 11 Apps with Swift by Stanford (cs193p) is available for free from

The lizard brain can seriously inhibit intelligent decision-making. It’s not that the decision will even sound wrong, under the circumstances it might well be the right thing to do. But the threat might only be perceived and the danger not be real. It could be just a false alarm that triggers the sense of danger.

The truth is that the real danger is willing to sacrifice dreams for “perceived” reality. Perceived reality is often scary. And fear is the real dream killer.

How to tell? We feel bad when we don’t get to do the thing we really want to do. We can fool ourselves in to thinking that it’s not really that bad. But the test is simple. How do you feel? Are you doing the thing that brings you the highest joy? Are you acting on your highest passion?

While the “escape” key has been the usual norm to exit “insert mode” into “visual mode”, the original vi editor encouraged and heavily used the “ctrl+[” keybinding to exit visual mode. Why should we care? Because “ctrl+[” is a lot closer to the fingers and more ergonomic, while hitting the “escape” key moves the left hand out of the home row position. Of course we assume that you remapped your Caps key to ctrl also 🙂

Here is the entry for the Sublime Text keymap file to bind “ctrl+[” to “escape” into visual mode:

{ "keys": ["ctrl+["], "command": "exit_insert_mode" }

On a sidenote: I cannot think of anyone would need to use the Caps key on a computer keyboard. Context is everything, the Caps key was important in the typewriter days because how else can text be made bold or italic. Capitalizing text was often the norm and it did’t indicate shouting as it does now.

The original vi manual, rather the paper “An Introduction to Display Editing with Vi” by Bill Joy has a very useful and quality tutorial that I have not seen matched even by commercial modern Vim/Vi books. You can get the PDF from the vi docs section here.

Professor Paul Hegarty of Stanford University teaching Developing iOS 10 Apps with Swift, from Lecture 1, graphite on copier paper, 8.5″ x 11″

The course Developing iOS 10 Apps with Swift by Stanford has been around for a while (about 6 months) free on iTunes:

Had been following the course since the Objective-C days and it’s time to take the latest version in the same tradition.

Here are the course contents based on the 17 lectures :

1. Introduction to iOS 10, Xcode 8 and Swift 3
2. MVC; iOS, Xcode and Swift Demonstration
3. More Swift and the Foundation Framework
5. Gestures and Multiple MVCs
6. Multiple MVCs, View Controller Lifecycle, and Memory Management
7. Error Handling, Extensions, Protocols, Delegation, and Scroll View
8. Multithreading and Text Field
9. Table View
10. Core Data
11. Core Data Demo
12. Autolayout
13. Timer and Animation
14. Dynamic Animation Demo
15. More Segues
16. Alerts and Action Sheets, Notifications, Application Lifecycle, and Persistence
17. Accessibility

Will publish the code like before on Github but this time will put all the projects and assignments in one repository:

So follow along, if you want, with me and feel free to point out if my code can be improved or if the projects and assignments can be done better 🙂 Good luck!

Naoki and Kozue waiting for the bus

Naoki and Kozue waiting for the bus

I think Eureka is one of those great movies that you want to keep going back again and again.

Without going into a plot summary or possible spoilers, here are my feelings about the movie:

There are events that happen in life that need time to resolve. We may call them life-changing events, they happen whether we like it or not. There is a cycle of head-on collision with anger and frustration at first, then perhaps a period of time needed to make a simple decision to start-over and evolve. The time needed may be short or many years. Eventually we are faced with the decision to evolve, there is no other choice. We may become better human beings – lose our prejudices, care and do what’s needed. Perhaps the definition of such lofty actions also change. Perhaps from a different vantage point, they are the most natural thing to do.

I think the trailer (with it’s theme song Eureka, by Jim O’Rourke) does justice to what you can expect from the movie.