简体   繁体   中英

Cocoa frameworks that don't need to be #imported

I noticed that after adding certain frameworks to a project in Xcode, you don't have to import any of its header files in order to access its classes. How come those classes are "magically" available without the import?

Look for yourProjectName-Prefix.pch file. There you'll find:

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

Inside the #ifdef statement you can add any files you like that will automatically imported throughout you whole project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM