Reputation: 4980
I have 2 files, somefile.h
and somefile.m
. I would like to combine them both into a single .m file (Long story as to why.) But, my AppController uses the somefile for a few of its calls. So, in the top of my AppController, I have an #import "somefile.h"
. Obviously that .h file is going to be deleted when I combine these files. So, could I just use #import "somefile.m"
and still have everything work?
Thank you!
Upvotes: 2
Views: 5423
Reputation: 27506
I just made a test and it looks like this is possible.
I was able to import the following .m
file and use it. But I had to remove it from the Compile Sources list first:
#import <Foundation/Foundation.h>
@interface MyClass : NSObject
+ (void)staticMethod;
- (void)instanceMethod;
@end
@implementation MyClass
+ (void)staticMethod
{
}
- (void)instanceMethod
{
}
@end
However, this is still a bad practice that you should avoid.
Upvotes: 2
Reputation: 1058
Not really, Objective-C works like C or C++, you can only import header files, not implementation files.
Upvotes: 0