How do I add an action or outlet to a class in Xcode 4.3.1?

冷暖自知 提交于 2019-11-28 05:46:13

问题


I'm following a slightly outdated the guide from cocoalab.com (Become An Xcoder) to learn the basics of cocoa, but I'm stuck on one of the instructions.

On page 45 (section 08:9) in the section titled "Creating connections", it tells me to select the instance of my new class, and from the identity inspector, to add two actions and an outlet.

I'm using Xcode 4.3.1 which is obviously a bit different to the version that this tutorial was written for, but I can't figure out how to do the equivalent in this newer version.

Can anyone please help by giving me step by step instructions of how to add these to my object.


回答1:


Open the Assistant Editor (red rectangle in the screenshot). Then, from Interface Builder, press the ctrl key and drag the mouse from the button (or an other control in you view) to the .h file.

You will be prompted to choose the type of the connection to create as in the screenshot below:




回答2:


I would suggest to follow the nice and easy tutorial on developer.apple.com - search for "Your First iOS App".

This explains how to add an outlet, and an action - all using the latest version of XCode. Won't take you long to do, but will get you up to speed with all the features you need.

Hope this helps :)



来源:https://stackoverflow.com/questions/9779069/how-do-i-add-an-action-or-outlet-to-a-class-in-xcode-4-3-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!