Wojtek
Wojtek

Reputation: 1308

How can I check the built-in function implementation in Objective-C?

I would like to ask if there is a possibility to check a built-in function implementation in Xcode IDE. I mean - is there something like CTRL + [click on function name] in IntelliJ? I need to check arc4random() implementation.

Upvotes: 3

Views: 745

Answers (3)

trungduc
trungduc

Reputation: 12154

In Xcode, you can hold command + click on function name to jump to file which function is defined (.h file).

If it's a built-in function, you can only see in .h file (Header file). You can't open built-in function in .m or .ccp file.

With arc4random() you can open stdlib.h but you can't check how it's implemented from XCode. Luckily you can check it here https://opensource.apple.com/source/Libc/Libc-997.90.3/gen/FreeBSD/arc4random.c.

opensource.apple.com is provided by Apple

EDIT:

To open stdlib.h from Xcode

  • Step 1: command + click to arc4random()
  • Step 2: Look at navigation bar

enter image description here

  • Step 3: Right click on stdlib.h

enter image description here

  • Step 4: Click on include folder and you will see what you want.

enter image description here

Upvotes: 5

Dielson Sales
Dielson Sales

Reputation: 1736

You can't access this specific implementation because it is Operating System's specific. But I think it's pretty likely that it's the same as BSD's implementation, since the Apple documentation describes it as "BSD Library Functions".

Edit: Being more specific, this function is part of the C standard library, and it's common practice to simply link it with the binary version distributed as part of the OS. So only the headers are normally available. Apple makes their libc source code available in the http://opensource.apple.com site though.

More broadly speaking though, you won't find the implementation of most Apple-related frameworks, except maybe Foundation, which is currently open source, and the Swift standard library.

Upvotes: 2

Rishi Chaurasia
Rishi Chaurasia

Reputation: 528

you can't check implementation because it is defined in stdlib.h and you don't have its implementation file access.

Upvotes: 1

Related Questions