Xcode : import folder/group
Is it possible to import a folder/group in stead of importing file per file in the .m ?
Example file per file:#import "FirstViewController.h"
#import "SecondVi开发者_JS百科ewController.h"
#import "ThirdViewController.h"
So it is possible to make it like that (folder contains first-second and thirdviewcontroller) :
#import "Folder"
Is it possible ? Cause it's very annoying to import file per file when you have a lot of files
You can't directly import everything in a folder, but you can make an extra header file that does all of the imports in one place. Then you just import the new header file wherever you need it.
e.g. in a new ViewControllers.h
file put just these lines:
#import "FirstViewController.h"
#import "SecondViewController.h"
#import "ThirdViewController.h"
And then put #import "ViewControllers.h"
wherever you need it.
Nope, but you can import your files in the precompiled header, so you import them just once, and they will be available globally...
EDIT
Imagine your project's name is MyApp.
You got a precompiled header filed named MyApp-Prefix.pch
#import <Availability.h>
#ifndef __IPHONE_3_0
#warning "This project uses features only available in iPhone SDK 3.0 and later."
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
/* Your imports here */
#endif
This particular header file will be automatically imported in all your files, so you can add here the #import
directives you need, so you don't have to write them on all your files.
精彩评论