如何在 Xcode 4.3.1 中向类添加操作或插座?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9779069/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I add an action or outlet to a class in Xcode 4.3.1?
提问by Grezzo
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.
我正在遵循 cocoalab.com(成为一名 Xcoder)的一份稍微过时的指南来学习可可的基础知识,但我被困在其中一个说明上。
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.
在第 45 页(第 08:9 节)的标题为“创建连接”的部分中,它告诉我选择新类的实例,并从身份检查器中添加两个操作和一个出口。
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.
我使用的是 Xcode 4.3.1,它显然与本教程所针对的版本略有不同,但我不知道如何在这个较新的版本中执行等效操作。
Can anyone please help by giving me step by step instructions of how to add these to my object.
任何人都可以帮助我逐步说明如何将这些添加到我的对象中。
回答by sch
Open the Assistant Editor(red rectangle in the screenshot). Then, from Interface Builder, press the ctrlkey and drag the mouse from the button (or an other control in you view) to the .h
file.
打开助手编辑器(屏幕截图中的红色矩形)。然后,从Interface Builder 中,按下ctrl键并将鼠标从按钮(或您视图中的其他控件)拖到.h
文件中。
You will be prompted to choose the type of the connection to create as in the screenshot below:
系统将提示您选择要创建的连接类型,如下面的屏幕截图所示:
回答by Stretch
I would suggest to follow the nice and easy tutorial on developer.apple.com - search for "Your First iOS App".
我建议遵循 developer.apple.com 上的简单易用的教程 - 搜索“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.
这解释了如何添加插座和动作 - 全部使用最新版本的 XCode。不会花费您很长时间,但会让您快速掌握所需的所有功能。
Hope this helps :)
希望这可以帮助 :)