67

I have a function in my *.m file

- (void)myFunction {}

How can I find the line number this function?

Abdurrahman Mubeen Ali
  • 1,331
  • 1
  • 13
  • 19
Voloda2
  • 12,359
  • 18
  • 80
  • 130
  • in the function or in the source file? The source file is one of the editor options (IIRC) – KevinDTimm Mar 19 '12 at 12:13
  • 2
    possible duplicate of [Xcode -- see the number of the line of code I am on?](http://stackoverflow.com/questions/5901758/xcode-see-the-number-of-the-line-of-code-i-am-on) – Pang Jul 08 '14 at 02:33
  • Please file bugs at http://bugreport.apple.com and reference radar://9245044 (for showing cursor line & column) or radar://13255659 (to show line numbers in the editor by default). – Quinn Taylor Oct 19 '15 at 22:12

8 Answers8

171

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.

Jason
  • 8,400
  • 10
  • 56
  • 69
Simon Whitaker
  • 20,506
  • 4
  • 62
  • 79
5

Go to Xcode Preferences > Text Editing > Show: Line numbers to show the line numbers on the editor.

neilvillareal
  • 3,935
  • 1
  • 26
  • 27
4

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);

For example, in some class called MyClass:

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

==== Output ===

Function: -[myClass someFunction]          Line: 175
Luffy
  • 401
  • 5
  • 10
3

If you type command L and enter the desired line number, then you can jump to the line number in Xcode 5.

Adam Freeman
  • 1,271
  • 12
  • 20
3

In Xcode 7

Xcode > Preferences > Text Editing
check the Line numbers

jacinth
  • 31
  • 2
1

Still applies in Xcode 8

Xcode > Preferences > Text Editing

mouness2020
  • 241
  • 3
  • 8
1

Shortcut cmd+L. Enter line number.

or

cmd+O. $CLASS_NAME:$LINE_NUMBER.

And your XCode goes to the line and highlights it!

Illya Krit
  • 925
  • 1
  • 8
  • 9
0

Keep Xcode top on Mac-Screen than press "command" and "comma key btn" a xcode preferences popbox will open given below:enter image description here than click on "Text Editing" menu below given window will open enter image description here here you on top written "show" with "Line numbers" just check it and thats it.

Happy Coding!!!

MRizwan33
  • 2,723
  • 6
  • 31
  • 42