简体   繁体   中英

How do you see or manipulate the code behind the views you create?

I'm trying to figure how to look at or manipulate the code behind views I've created in tutorial applications I've copied.

I understand that you are supposed to "control" the views using a view controller. The part that's confusing me is that when I follow the tutorials, I'm clicking on my view objects, setting the delegate, but I don't see where that is acutally happening in the code. Are you able to see the code that makes up a view or is that totally hidden from you?

You mean when you are dragging views around visually when you open a nib?

The objects you create and the connections you make are saved to an XML file. When Xcode builds your application, these are then converted to a more efficient binary file format.

When your application runs, the binary file is read, and the objects described within are instantiated. Where connections are made, the nib loading part of the platform uses Key-Value Coding to set the outlets and properties on related objects, most often the nib owner.

You can see the XML representation of your views by right-clicking on the nib in the project navigator panel on the left-hand side, then selecting Open As | Source Code .

You need to go through Apple's " Your First iOS App " guide, and read it, do it, and reread it until just that basic tutorial sinks in.

If you use Interface Builder to create a view (it will create that view in a nib file), you will connect that with a view controller that will consist of an interface file and an implementation file. Within these files you will place code by which you will reference those components in the view, and you will also code methods that will give you behaviors and operations that can be triggered or can manipulate components and data of that (or other) views.

You just need to really digest Apple's documentation better. They have wonderful guides to help you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM