Sunday, October 29, 2017

Build a Basic UI

Back | Forward



Chapter 1 of 10 at Apple Developer > Jump Right In is Build a Basic UI.


Hope for a bot to think with


Apple picks a first goal for your app: it must learn to listen, to speak, and to act.


You tell your app to listen inside its UITextField, you tell it to speak out thru its UILabel, you tell it to act when some human taps its UIButton.


Apple leads with the sneer of "Basic" and the alphabet soup of "UI", but they mean well


<= Learning Objectives




Find the answers in the back of the book


Each chapter of the tutorial ends with a copy of Apple's solution. Glance into it as often as you want, to compare their solution with yours.

You can open the project folder in Xcode, or its '.xcodeproj' file, or compare the text of the files of one project with another

<= Learning Objectives


Don't replace all the example texts


Apple means to say you should create some new folder to work with Xcode, such as "~/Documents/Xcode-Projects". Inside that folder you place your Xcode Projects. Each Project is its own Git Repo.


Apple means to say you can leave the Organization Identifier set to "com.example". They don't mean to say you must spell your own name backwards, as with "org.ieee.doe.jq".


Apple means to say you can give no Organization Name at all, you don't have to name yourself as an organization, you don't have to name some other organization.


Curiously, Apple prints no copyright claims into your code if you name no organization. If you do name an organization, then Apple puts claims into your code to say you assigned your copyrights to them.

Apple doesn't invite you to claim copyright and doesn't applaud you giving anonymously


<= Create a New Project

<= Get Familiar with Xcode



Pick one iPhone to simulate


Beware, Xcode will leave stale versions of your app behind on every iPhone you simulate.

That gets wildly confusing if you try more than one iPhone. Xcode will frequently slap you back into choosing its default choice. Either you take its default as mandate, or you learn to delete old versions of your app.

Xcode shrugs off much of the work of distributing your apps under test

<= Run iOS Simulator


Expect to start twice


Apple develops Xcode with all its security turned off.

If you're typing a password every time you restart Xcode, you're working harder than they do, and you'll notice that your first launch of the iPhone Simulator fails, because you didn't type out your password in zero time. No big deal, once you understand. You just start again.



Xcode doesn't encourage you to aggressively defend your own MacBook



<= Run iOS Simulator


Watch your iPhone simulation catch up


The first iPhone that Xcode shows you won't look the same at first as it does later. Xcode lets you run ahead and get started even as it is slowly slowly filling out the phone for the first time. It is busy installing a dozen apps alongside yours, you just don't get that news unless you ask for it.

Apple forgets to tell you how it is disrupting your world

<= Run iOS Simulator


Race ahead


Apple invites you to review the "AppDelegate.swift" file, as if that file contained words you would find pertinent as you work thru this tutorial. It doesn't. You can skip it.

Apple forgets to respect your time intensely

<= Review the Source Code
<= The App Delegate Source File


Walk backwards


Apple has somehow chosen to come off as arrogantly imagining their words are perfect. They say just tell you, yea, you do what we meant to tell you, without ever walking you thru how to undo any misunderstandings. As if that could ever be real.

So early on, find your way to the major kinds of Undo that work better than:
Edit Undo        ⌘Z
Experiment with:
Product > Clean        ⇧⌘K 
Yea I mean it        ⌥⇧⌘K 
Push so hard as to learn the destructive:
Source Control > Discard All Changes
You'll have to redo what you just did when you try that, but it's worth it, because here you learn how to undo what you did wrongly by accident, when you don't even know what it was that you did wrong.

If you know Git, you can Quit Xcode, drop down into the Terminal, and learn to destroy the rest of your changes like so:
git log 
git reflog
git status --short --ignored 
git clean --ffxdq
That extreme technique for destroying all your work is even more thorough than the choices Xcode gives you. That sharp scalpel will likely go wrong if you forget to quit Xcode or if you haven't already learned Git. For instance, that sharp scalpel will delete all new files.

Apple has forgotten the courtesy of always inviting you to undo what they misunderstood

<= The View Controller Source File
<= Open Your Storyboard


Notice Editor is not Edit


Yes, it's true, Xcode has one menu named "Editor" and another named "Edit", just to feed the pain of all humans who find those two words extremely similar.

Likewise, this very tutorial has this entire chapter named "Build the Basic UI" and also a subchapter also named "Build the Basic UI", as if naming a child after a parent.

Apple has forgotten the courtesy of giving totally different names to totally different things

<= Build the Basic UI


Distrust enough defaults


Editor > Canvas > Show Bounds Rectangles will shut off and stay off till you discover it.

Did you catch that? Xcode will choose to turn things off that you need before you discover they exist.

Xcode neglects its duty to give first preference to the newest guest

<= Build the Basic UI


Frequently correct the Zoom


Xcode frequently requires you to rework its zoom. They hide that choice inside of Editor > Zoom > Zoom To Fit. You can also find it if you right-click. You may notice there is a Zoom control you can click into, but it just gives you hard numbers like "75%", it rudely neglects to offer "fit".

Apple does think hard enough and talk long enough to mention you might need to zoom in, but they neglect to mention you often want to zoom to fit and you sometimes want to zoom out.

Xcode doesn't volunteer to show you what you need to see

<= Build the Basic UI


Expect Xcode will be slow to hear you


As often as they tell you press the Return key after you change something, they really mean it. Xcode can sit for hours without taking notice of your input, unless you make a point of pressing Return or clicking to highlight a different input.

Xcode doesn't limit how long it ignores you

<= Build the Basic UI


Let Apple waste some time


Apple pushes you into the Assistant Editor Preview as if it were useful.

It's not useful yet, but it will be useful. Take this one on faith. You'll soon learn to choose from a series of previews. The quickest previews are the least accurate, the slowest previews are the most accurate. This preview is not as quick as a glance over the storyboard, and not yet any more accurate, because your app is still too simple for that. 

Apple's gives you a good or fast experience in Xcode, never both at once

<= Preview Your Interface


Let Apple misuse technical words


For a piece of Swift code to "adopt a protocol" is a specific technical thing you'll soon learn. Apple's first mention of the word "adopt" has nothing to do with that specific thing. It's a strangely unnatural word choice, no kind of plain language.

Apple has forgotten the value of careful word choices

<= Adopt Auto Layout



Let Xcode lose your new constraints


Xcode really will casually discard all your input inside its Add New Constraints popup.


You have to read and understand the tutorial of how to work that popup, and only then go work that popup from start to finish. As often as you stop in the middle to switch focus back to the tutorial, you have to start over.


Apple has forgotten the value of stepwise improvement.


<= Adopt Auto Layout




Learn debugging later


Apple neglects to mention that the new constraints appear in the Outline View. Make time to find them there. Otherwise, you won't have any way to review your work. You won't know how often you wrongly accidentally create too many constraints, too few constraints, or some constraints with the wrong values.

Apple talks as if you're likely to have departed from their instructions far enough to make use of Update Frames, Resolve Auto Layout Issues, Reset to Suggested Constraints, and Choose Clear Constraints. Tell us if you do, I never have.

Apple has forgotten the value of immediate visual feedback

<= Debugging Auto layout



Download and compare


Apple does end this chapter, its chapter 1 of 10, with a download named "01_BuildABasicUI".

You can download that work and compare that work with yours. It will have the same "FoodTracker" name as your work, which can be confusing, so you might should make a point of forgetting about it, by choosing Xcode > File > Open Recent > Clear Menu.

If you know Terminal Diff, then you can get a lot of learning out of telling your MacBook to highlight every small difference between their work and yours.
cd ~/Downloads/01_BuildABasicUIcd ~/Documents/xCode-Projects/FoodTrackerdiff -burp ~/Downloads/01_BuildABasicUI .
The space-dot " ." on the end of those instructions is crucial, and easy to overlook.

Apple forgets to strongly recommend you compare your progress with theirs

<= Wrapping Up


Back up your progress



If you know Git, you should make the Source Control > Commit choice now. Your Commit Message could be "Build a Basic UI". This choice captures your progress now, so you don't lose it, so you can always come back to it. This choice moves the baseline, so you that Source Control > Discard Changes brings you back here, after now.

If you don't know Git, you've still got to find some way to capture progress. Odds on you can quit Xcode and copy the project folder to back it up. I haven't tried that, but it looks like it works.

Mostly, if you're coding in 2017 without knowing Git, now is a good time to catch up. Xcode Source Control might be intuitive enough to pick up quickly. Tell us how it goes? Tell us if Xcode loses some of your work as you learn?

Apple leaves your Discard Changes defined to slap you all the way back to your beginning


<= Wrapping Up




Back | Forward | Source: Apple Developer >  Build a Basic UI

Jump Right Into iOS Apps




Welcome


Writing your first iOS App? Working thru Apple Developer > Jump Right In?

Take our map of their pitfalls with you.

Jumping right in to their tutorial is a good idea, because Apple has solved the technical part of how to invite you in to win. They've picked out a quick simple path thru a huge swirling blizzard of details that could distract you. Work thru just 4 chapters and you have an app up and running. Work thru just 9 chapters and you have an app that remembers stuff even when you turn off the iPhone.

What they've left broken is a small flood of misleading details, placed to trip you up: things that scream and scream a lie: the lie that this is not for you. In reality, you'll soon be skilled enough. You won't need any more help from us after you begin to know more and more of what Apple imagines they told you to know, and actually forgot to mention. You might be good on your own as soon as the 3rd chapter. Tell us how it goes?

Apple has lost the knack of keeping discovery simple


Jump right in


iOS Apps for your phone should be easy to write, because free speech. Apple knows this truth so well as to invite you and me to jump right into their free tutorial.
Apple Developer > Jump Right In 
Here we tell you how they've set you up to fail. Read this blog, and you won't waste so much of your life on reverse-engineering every trap that they've laid for you.

We are strong, because public - they are weak, because corporate



Don't go learn Swift


Fair enough, you must go learn Swift first if you and all your friends don't already know Python or Java or C++ or some other object-oriented programming language of this 21st century. Fair enough, you should learn Python or Java or C before you learn something messier.

But if you do know about programming objects, then you don't have to go learn Swift before you ship your first app. You will find Swift quirky, but no more quirky than all the rest of Xcode: InterfaceBuilder, Cocoa, ObjC, and so on and on.

Some feel no shame in speaking of an "implicitly unwrapped optional variable of type"


Do download Xcode


Download the Xcode App from the App Store, into your Mac OS X.

If you have no Xcode, this is an easy and obvious choice, you are blessed. Otherwise, this choice is your first pitfall. For instance, the Terminal App you open in 2017 can fool you into downloading a 2015 Xcode 7.3.1 (7D1014) onto a 2016 macOS Sierra.

Ask me how I know.

The surprise is that you have to work to get the latest. The joy is that it's easy. Just go visit the App Store and pull it down. Don't settle for less than Xcode 9.0.1 (9A1004) in 2017, demand a new free Xcode 10 in 2018, and so on.

Many people know today as 2017, a proud few know today as the year of Xcode 9

Don't expect documentation will exist


All the pain of you running one Xcode while Apple talks of another, all that pain will be ours to share here.

Apple should show their respect for free speech by keeping up with the times. They should ship an insanely great tutorial as part of each Xcode. They did ship the Xcode tutorial for Sep/2015 in Sep/2015. They did ship the Xcode tutorial for Sep/2016 in Dec/2016. They still haven't yet shipped the tutorial for Jun/2017, and it's Nov/2017 now.

You can run the latest Xcode on the Mac you have, & talk out your pain with all of us here. Me, I first tried this on a macOS Sierra 10.12.16 with Xcode 9.0.1 (9A1004). But get this: I'm still happy to talk with you, no matter your choice of what version to run.

Apple hasn't found the discipline to write their doc before they ship the code


Don't match your version to theirs


Apple has somehow chosen to come off as dishonest. They lead with an unbelievable story. They pretend you can easily match your version to the version they bothered to document. They pretend you can then easily adjust to run something more current.

You can diss their nonsense, as quickly as you learn to pick it out



Get ready to spend money


Apple lets you write apps, run them, and screen-shot them on a good slow simulator of an iPhone. All for free, bundled into your Mac OS X.

But the Apple security on your iPhone will lock you out from running your own apps, except while you subscribe as an Apple Developer. That's like US$100 per year, plus sales tax, plus surrendering your anonymity.

Somehow they don't mention the full price up front



Back | Forward | Source: Apple Developer > Jump Right In

Blogspot met Pat



"You should blog", she told me.


"I like signal, I don't like noise."


"You can only write enough nonfiction if you write much too much at first, and then cut it back, like a sculptor shaping stone."

"Ok, I can do that. Hobbits like to fill the web with things that they already know, set out fair and square with no contradictions."


For instance:

Google Search: Pat+AND+silence


Sources: NIST, JDidion, JRRTolkien