In C if we include #stdio.h we get some functions like printf, scanf. In the same way for Objective C what we should do to include NSLog,NSArray,... and where the definitions of these NSLog, NSArray are stored ? Please clarify my confusion.
Adding to what jib wrote: to use those functions, one puts a line
#import <Foundation/Foundation.h>
at the top of the source code. This corresponds to #include <stdio.h>
in the standard C.
In OS X,
#import <FirstPart/SecondPart.h>
reads the header file at FirstPart.framework
somewhere in the framework search path (typically, /System/Library/Frameworks
) and then the SecondPart.h
is looked up inside FirstPart.framework/Headers/
. So, in the case of #import <Foundation/Foundation.h>
, the file is at /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h
. Now, if you open that file, you see it just have lots of other #import
's, as in :
#import <Foundation/NSObjCRuntime.h>
#import <Foundation/NSArray.h>
#import <Foundation/NSAutoreleasePool.h>
....
and the real definitions are in those files. In general, you shouldn't import those individual headers, but should just import the main header (in this case Foundation/Foundation.h
); the compiler has an optimization which makes it faster that way.
NSLog, NSArray and other basic classes are included in Framework.h file. To import all these classes in your program simply add
"#import Framework\Framework.h" and leave rest for the compiler.