davewp
davewp

Reputation: 243

NSStringFromClass() is invoked by UIApplicationMain(), but Foundation.h is not imported in main.m

(a) The 4th parameter in the UIApplicationMain() method is the method: NSStringFromClass()
(b) NSStringFromClass() is found in Foundation.h
(c) The only import into main.m is UIKit.h.
(d) As best I can tell, UIKit.h does not extend the Foundation.h

So, why am I not getting an error when I compile main.m? NSStringFromClass() should be an unrecognized method?

Upvotes: 1

Views: 176

Answers (2)

Scott Berrevoets
Scott Berrevoets

Reputation: 16946

Foundation is imported in the precompiled header that comes standard with every Xcode project:

//
// Prefix header for all source files of the <x> target in the <x> project
//

#import <Availability.h>

#ifndef __IPHONE_3_0
#warning "This project uses features only available in iOS SDK 3.0 and later."
#endif

#ifdef __OBJC__
    #import <UIKit/UIKit.h>
    #import <Foundation/Foundation.h>
#endif

Upvotes: 3

LombaX
LombaX

Reputation: 17364

Have a look at the macro in the *prefix.pch file in your project supporting files ;-)

Upvotes: 3

Related Questions