discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

splitting a class in pieces, compile-time dependent


From: Riccardo Mottola
Subject: splitting a class in pieces, compile-time dependent
Date: Tue, 23 Jul 2013 18:05:23 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:22.0) Gecko/20100101 Firefox/22.0 SeaMonkey/2.19


MyClass.m

@implementation MyClass

- (void)method
{
#ifdef A
A stuff
#else idfef B
B stuff
#endif
}
@end

So I have conditional code, switched at compile time, which is just fine. However I have actually many more ifdefs (each representing an operating system) and the code got unreadable.

I want to find a good way to split this in MyClass-A, MyClass-B, etc by adding the least possible logic and especially keeping everything static ad build time (not runtime).

I thought of extending the class

MyClass(A)

-(void)methodA{}

and then in the MyClass udate doing something:
- (void)method
{
#ifdef A
[self methodA];
#else idfef B
[self methodB]
#endif
}

But hits is bogus: "MyClass" gets instantiated, nothing is known about methodA and thus an exception will be thrown.


Can this method be refined? Or do you have different suggestions?


Riccardo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]