0003 – 15 Minutes For A Done Button
As of last night I’m at about halfway through the second lesson in the iOS Apprentice course. The second course is building a “Checklist” app that has the most basic of to do list functionality. In the section last night I was learning how to create a new view to slide in when a user wanted to add a new item. I was impressed to learn that the iOS SDK includes default buttons for common things like Done and Cancel so you can just create a button and tell the system that it’s a Cancel button.[1]
The thing that learning programming is really driving home to me is that computers are dumb machines. You might assume that once the system knows a button is a Done button that it will close the view for you, but you would be very wrong. I knew this kind of thing already, but I keep getting reminded how every little thing has to be spelled out for the computer. Over the following 15 minutes I learned how to actually make the Done button do the things you probably don’t even realize have to be programmed:
- When tapped, the Done button should animate the Add Item view away.
- When tapped, the Done button needs to instantiate a new ChecklistItem object, grab the text the user has entered, and send it to a delegate to add it to the data model.
- The Done button should be disabled if no text is in the Text Field to avoid sending an empty ChecklistItem back to the data model. This means that with each tap on the keyboard the AddItem screen checks the Text Field.
- The Done button should be told to start in a disabled state since by definition when the view appears there will be no text in the Text Field, but it won’t have yet checked the Text Field since no keyboard keys will have been pressed.
All of this takes explicit lines of code just to get up to what most would consider the basic functionality of a Done button.
After working through this I called it a night and went out to the living room where my roommate was playing Assassin’s Creed on PS4. After seeing the nuts and bolts of a simple Add Item screen in a basic Checklist app, it was mind-blowing to have a sense of what it would take to make a real-time responding, 60fps 3D world with lights and shadows and AI characters and thousands of objects interacting.
I have a lot to learn.
-
You don’t even have to type Cancel! ↩