O'Reilly logo

Cocoa Programming for OS X: The Big Nerd Ranch Guide by Aaron Hillegass, Adam Preble, Nate Chandler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required