I'm learning objective-C and Cocoa. In the Apple tutorial I'm working through there's a side note that says:

IBOutlet is a null-defined macro, which the C preprocessor removes at compile time.

I'm curious - what's a null-defined macro?

Cheers Ben

+8  A: 
#define IBOutlet

Whenever IBOutlet is used in program text, it will be replaced with nothing at all.

Greg Hewgill
+8  A: 

FYI, in this particular case, the reason the IBOutlet even exists is simply so that Interface Builder can parse the source file and glean bits of understanding from it. It's a clue (well, a bit stronger than a clue) that the variable preceded by IBOutlet should show up as an Outlet in Interface Builder when designing your UIs.

Matt Dillard
+6  A: 

A null-defined macro is a macro which will be replaced by nothing (will be removed) by the preprocessor. It's role is to give a hint about something in code, such as:

#define IN
#define OUT
#define INOUT

int myFunction(IN char *name, INOUT char *address, OUT char *phone);

This declaration suggests that name is a input variable for the function, address is both input and output, phone is an output variable.

That's really cute. Reminds me of Ada (obviously).I prefer to prefix the parameter name with in or out. But same effect.

Also - if you're unsure how anything is defined - command double-click it and Xcode will open the definition in the original source file.


Oh and while I'm at it. Option double click will (attempt to) open up the documentation for the double clicked symbol.

Why don't you merge the two answers and delete one?