简体   繁体   English

如何在 Xcode 中找到行号?

[英]How can I find a line number in Xcode?

I have a function in my *.m file我的 *.m 文件中有一个函数

- (void)myFunction {}

How can I find the line number this function?我怎样才能找到这个函数的行号?

You can go to:你可以去:

Xcode > Preferences > Text Editing

then tick "Line numbers".然后勾选“行号”。 Go to your method and you'll see the appropriate line number shown in the left-hand border of the text editor.转到您的方法,您将在文本编辑器的左侧边框中看到相应的行号。

转到 Xcode Preferences > Text Editing > Show: Line numbers 以在编辑器上显示行号。

This can also be done through code when your implementation file grows.这也可以在您的实现文件增长时通过代码完成。 I have found this very useful to track and debug through tedious code.我发现这对于通过乏味的代码进行跟踪和调试非常有用。 NSLog(@"\\nFunction: %s\\t\\tLine: %d\\n\\n", func , LINE ); NSLog(@"\\n函数: %s\\t\\tLine: %d\\n\\n", func , LINE );

For example, in some class called MyClass:例如,在某个名为 MyClass 的类中:

- (void) someFunction {
    NSLog(@"\nFunction: %s\tLine: %d\n\n",__func__, __LINE__);
}

==== Output === ==== 输出 ===

Function: -[myClass someFunction]          Line: 175

如果键入 command L 并输入所需的行号,则可以跳转到 Xcode 5 中的行号。

In Xcode 7在 Xcode 7 中

Xcode > Preferences > Text Editing Xcode > 首选项 > 文本编辑
check the Line numbers检查行号

Still applies in Xcode 8仍然适用于 Xcode 8

Xcode > Preferences > Text Editing Xcode > 首选项 > 文本编辑

Shortcut cmd+L .快捷键cmd+L Enter line number.输入行号。

or或者

cmd+O . cmd+O $CLASS_NAME:$LINE_NUMBER. $CLASS_NAME:$LINE_NUMBER。

And your XCode goes to the line and highlights it!你的 XCode 转到该行并突出显示它!

Keep Xcode top on Mac-Screen than press "command" and "comma key btn" a xcode preferences popbox will open given below:将 Xcode 保持在 Mac 屏幕上,而不是按“命令”和“逗号键 btn”,一个 xcode 首选项弹出框将打开,如下所示: 在此处输入图片说明 than click on "Text Editing" menu below given window will open比点击“文本编辑”菜单下面的给定窗口将打开在此处输入图片说明 here you on top written "show" with "Line numbers" just check it and thats it.在这里,您在上面用“行号”写了“显示”,只需检查它就可以了。

Happy Coding!!!编码快乐!!!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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