seguedestination
seguedestination

Reputation: 419

Objective-c how to import file programmatically?

How can I import file programmatically? For example:

@interface RoomModel : NSObject

#ifdef DEBUG

#import "fileA.h"   //error : missing context for method declaration

#else

#import "fileB.h"

#endif

@end

I know what that mean: I should declare the import in front of the interface. But if I want to import the .h file programmatically? Any ideas? Thanks

Upvotes: 0

Views: 219

Answers (2)

orkoden
orkoden

Reputation: 20006

You can't import at runtime, if that's what you're trying to do. It's a preprocessor command, that is executed before compilation.

Upvotes: 3

Muhammad Adnan
Muhammad Adnan

Reputation: 2668

import statements must be on top

#ifdef DEBUG
#import "fileA.h" 
#else
#import "fileB.h"
#endif

@interface RoomModel : NSObject

Upvotes: 3

Related Questions