In Xcode can you add code directly to an interface element?
In VisualBasic, you can add the GUI then click o开发者_如何学Cn an object (Button, label, etc.) and add its code.
Can I do this in Interface builder?
No. In Interface Builder (IB) and Xcode, you create links between interface elements and controller code via outlets and actions. This isn't as trivially easy as working with VS, but it encourages you to keep your View code and your Controller code separate; it promotes good practices.
The IB User Guide will give you everything you need to know to get started.
You create the GUI in Interface Builder; you write the code in Xcode.
Interface Builder lets you define outlets so that your code can talk to the objects, and action methods so that your interface objects can talk to the code.
See the Cocoa Fundamentals Guide for more precise definitions, and the Interface Builder User Guide for even more specifics.
精彩评论