随着大量的Xcode新手的涌入,我相信会有很多Xcode的技巧和技巧可以分享。

你的呢?


当前回答

使用类浏览器显示继承的方法

Apple's API reference documentation does not show methods inherited from a superclass. Sometimes, though. it's useful to be able to see the full range of functionality available for a class -- including a custom class of your own. You can use the Class Browser (from the Project menu) to display a flat or hierarchical list of all the classes related to a current project. The upper pane on the right hand side of the browser window shows a list of methods associated with the object selected in the browser. You can use the Configure Options sheet to select "Show Inherited Members" to show inherited methods as well as those defined by the selected class itself. You click the small book symbol to go to the corresponding documentation.

其他回答

使用]自动插入[到正确的位置

我来自。net背景,所以我习惯于输入一个符号,然后输入它的一个方法名。所以我总是忘记在开始输入对象名称之前包含[。通常这意味着我需要转到行首并手动添加[。我没有意识到我只需在当前光标位置按下],它就会自动添加。

有几种方法可以使用它:要么在输入函数名之后,要么在输入函数名之前。

方法一:在函数名后面

myObject testMethod]

... 就变成:

[myObject testMethod]

…插入符号位于]之后。

方法二:在函数名前面

myObject]

... 就变成:

[myObject ]

... 插入符号位于]的正前方。

后者(2)的优点是代码补全将根据对象的方法进行筛选。而对于前者(1),如果你试图在myObject之后立即调用代码补全,它将不会被过滤。(2)的另一个优点是它的行为更像其他使用点表示法的编程语言。然后只需输入对象的名称[而不是]。访问一个方法。

切换到头文件/源文件

选项命令⌘向上箭头↑ 查看>切换到头文件/源文件

在。m和。h文件之间切换。

在Xcode 4中,这是ctrl⌘向上箭头↑

调试-如何使用GDB

作为新手,我发现捕捉和识别错误相当困难 艰巨的工作。控制台,尽管它是一个强大的工具,通常 不会产生非常直观的结果,不知道你是什么 在调试器中查看也同样困难 理解。在他们的帮助下 和关于Stack Overflow的好文章 可以在 可可与爱,它变得更友好一点。

在Xcode的Groups and Files窗格中选择Group,然后Edit > Sort by > Name。

您可能希望在组的上下文菜单中找到它,但它不在那里。

Credit:在Xcode中排序文件。

1. "objc_exception_throw"的断点

在objc_exception_throw上应该始终有一个断点。

2. 调试“僵尸”变量的保留/释放问题

使用以下代码:

NSZombieEnabled = YES;
NSDeallocateZombies = NO;

... 调试保留和释放问题。要了解更多信息,请参阅Apple调试应用程序文档中的“查找内存泄漏”部分。

3.从Interface Builder跳转到Xcode中的类

命令⌘+双击接口生成器的文档窗口中的对象,跳转到Xcode中的该类。这对于File's Owner来说非常方便。

4. 在接口生成器中重用自定义对象

将自定义对象拖回接口生成器的库以供以后重用。

5. 在“接口生成器”中选择重叠项

控制⌃Shift +在Interface Builder中点击一个对象,可以看到鼠标下所有对象的菜单。

6. 界面构建器手势指南

界面构建器手势指南。