Begin Editing on Insert

Your app is coming along nicely, but your users will complain, “Why do I have to double-click to start editing after an insert? It is obvious that I am going to immediately change the name of the new person. Can’t you start the editing as part of the insert?”

Oddly, this is a little tricky to do. Open Document.swift. First, add two new outlets:

c​l​a​s​s​ ​D​o​c​u​m​e​n​t​:​ ​N​S​D​o​c​u​m​e​n​t​ ​{​
 ​ ​ ​ ​@​I​B​O​u​t​l​e​t​ ​w​e​a​k​ ​v​a​r​ ​t​a​b​l​e​V​i​e​w​:​ ​N​S​T​a​b​l​e​V​i​e​w​!​
 ​ ​ ​ ​@​I​B​O​u​t​l​e​t​ ​w​e​a​k​ ​v​a​r​ ​a​r​r​a​y​C​o​n​t​r​o​l​l​e​r​:​ ​N​S​A​r​r​a​y​C​o​n​t​r​o​l​l​e​r​!​
 ​ ​ ​ ​v​a​r​ ​e​m​p​l​o​y​e​e​s​:​ ​[​E​m​p​l​o​y​e​e​]​ ​=​ ​[​]​ ​{​

Next, while still in Document.swift ...

Get Cocoa Programming for OS X: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.