Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mduser63

macrumors 68040
Original poster
Nov 9, 2004
3,042
31
Salt Lake City, UT
Is there a way to (easily) access C language reference materials in XCode? I'm trying to write C in XCode and finding it difficult to look up syntax for functions, operator definitions etc. It seems like this should be easy, but I sure can't figure it out. The man pages sometimes work, but you generally have to know the name of the function you need info on to get any results, and even then it's not 100%. Besides, man pages are incredibly cryptic, and don't really have any example code which is necessary for me. I'm having to resort to web searches to find what I need which is annoying. Am I missing something, or is XCode's documentation/help system pretty bad?
 

HiRez

macrumors 603
Jan 6, 2004
6,265
2,629
Western US
Choose Documentation from the Help menu in Xcode. Whatever you search depends on what you have selected in the left column, so try the head node ("Reference Library") to search everything. Also, you can search API keywords or all documentation, so know which one you're searching. The search in Xcode leaves some things to be desired but it works ok and is a lot easier than guessing at man pages. Most of the C and UNIX functions are documented, and I think they actually read the man pages for UNIX functions. Rather than searching, you can try starting at the reference home page and drill down to more specific topics. I still find myself Googling a lot of things I want that I can't find in the Apple docs though.
 
It is some way off Visual Studio's level of integration but if you are using XCode 2 or higher the code completion is much improved: add your headers e.g. unistd.h and (I find necessary) rebuild and then it will give you the function prototypes pretty reliably, F5 bringing up the list.

I don't know if this is what you are doing already, but the quickest access I have found is to highlight your function name in the text editor, right click and then you should have the option to jump to the definition or API reference (the man pages). Sometimes you need to do this twice before the API option comes up. Reading man pages is a bit of an art but keep in mind that it gets much easier after a bit of practice.

You can set this to a short cut key in Preferences -> Key Bindings -> Help

Beyond that, yup, I have found the documentation and documentation access to be somewhat wanting. FWIW, I tend to keep Safari and external pages open on a second monitor.
 

slooksterPSV

macrumors 68040
Apr 17, 2004
3,544
306
Nowheresville
XCode->Preferences (CMD+,)
Code Sensing Tab
Enabled for All Projects or your current project. The F5 thing does work well though after you've included the header.
 

Jordan72

macrumors member
Nov 23, 2005
88
0
I've looked for this myself and could not find anything. I believe (do not know) that there is no way to look up a C function that has an example. In Objective-C you can look up methods, but most of the time you don't get an example. I'm sure this is because an example could double or triple the actual work to create a reference. As far as C goes, I think Apply may have assumed there is enough out ther already than to pay some one to create a reference for such a popular and well documented language. Objective-C is the main language for XCode and is documened well, but not documented well with examples. Big difference. Since they, for the most part don't include examples for their main language, Objective-C, I think if somewhere there did exist C function references, it would definitely not include examples for each function, which are absolutely necessary for beginners.

I suggest you type in google: c tutorial

or peruse, very carefully every major book store chain you can and pick the one that explains things for a couple of chapters to your standards. (And check for something obscure you already know to see if it mentions that for a test of it's thoroughness.)

You're probably restricted to books and the web.
 

caveman_uk

Guest
Feb 17, 2003
2,390
1
Hitchin, Herts, UK
Jordan72 said:
Objective-C is the main language for XCode and is documened well, but not documented well with examples. Big difference.
It's not the same thing as documentation with examples but the example projects installed with the dev tools often have interesting stuff in them...if only to see how the Apple guys would write an app. It really could do with a good index though.
 

Jordan72

macrumors member
Nov 23, 2005
88
0
caveman_uk said:
It's not the same thing as documentation with examples but the example projects installed with the dev tools often have interesting stuff in them...if only to see how the Apple guys would write an app. It really could do with a good index though.

I won't argue an app written by Apple developers is not the best example to have, but I would argue it isn't the best for beginners. Because, beginners are struggling with just the usuage of one peice, whereas an app is a conceptual example of those understood peices in action.

Perhaps there is a small group of C expert teachers out there that would enjoy the opportunity to write a C reference for XCode and do it well. If they did a superb and thorough job with a brief examples for every C function(and some important implications of it's use with other functions) and since XCode is free, I think it would decrease the time for those who are learning Apples platform, which means Apple has a larger pool of developers, quicker and those using XCode have an immediate and competent source. The question is, how valuable is that to Apple?
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
Tips:

Highlighting a word and then option-double-clicking it looks it up in the documentation.

Command-double-clicking it opens up the header where it's defined. Very useful for constants, enumeration values, etc.
 

caveman_uk

Guest
Feb 17, 2003
2,390
1
Hitchin, Herts, UK
Jordan72 said:
I think it would decrease the time for those who are learning Apples platform, which means Apple has a larger pool of developers, quicker and those using XCode have an immediate and competent source. The question is, how valuable is that to Apple?
The dev community is valuable enough to Apple for them to spend time and money putting together the dev tools and then give them away for nothing. As we know, Apple doesn't give much away for free:rolleyes:
 

Jordan72

macrumors member
Nov 23, 2005
88
0
caveman_uk said:
The dev community is valuable enough to Apple for them to spend time and money putting together the dev tools and then give them away for nothing. As we know, Apple doesn't give much away for free:rolleyes:

I believe giving away the developer tools is a strategy. I don't think it's an act of selfless giving as much as it's a strategy to create an environment where reciprocation will occur. The more accessible you make development, the higher the chance your platform will be productive.
 

mduser63

macrumors 68040
Original poster
Nov 9, 2004
3,042
31
Salt Lake City, UT
Jordan72 said:
I believe giving away the developer tools is a strategy. I don't think it's an act of selfless giving as much as it's a strategy to create an environment where reciprocation will occur. The more accessible you make development, the higher the chance your platform will be productive.

Exactly. My dad still complains about the fact that when he first bought a Mac back in the 80s, he planned to get good at developing Mac apps. Then he found out that you had to pay $500 or something to join ADC, and even then the documentation you got was quite poor. He almost doesn't believe me when I tell him that things have changed and that XCode comes free with every Mac.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.