On 27 Jul 2013, at 09:34, Riccardo Mottola <[email protected]> wrote:
> Hi, > > MicheleBert . wrote: >> 2013/7/23 Riccardo Mottola <[email protected]>: >>> 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 am not sure I understood well, but I can guess a suggestion? >> Could be done something like following? (I write in C++, but I think >> there is an objc equivalent) >> >> class MyClassSpecific >> { >> #if defined(_A_) >> <A stuff> >> #elif defined(_B_) >> <B stuff> >> #endif >> }; >> >> class MyClass : public MyClassSpecific >> { >> <common stuff> >> }; > That is essentially quite similar to the beginning code. But how do you split > this in different files? > > I ended up implementing David's version which actually works (thanks David). > The only thing which I don't like about that version is that the different > files are "included" in a class implementation file (.m) and not explicitly > in the makefile. I essentially tried to do the same thing, but with explicit > separation of headers and of course it didn't work. > If such a project had to be managed in ProjectCenter it wouldn't work, for > example: project files are added automatically to the make file. I checked > and "make dist" works, but it still might pose problems when distribution > make package lists. > > I still have stuff to improve, but for now I like the first clean-up, it made > the code (and also the necessary imports) much much better. The only dirty > part is actually my linux code which has tons of ivars. If you have common ivars, then you could just put all the system-specific code in separate categories in separate files: @interface MyClass : BaseClass { // ivars } // comon methods @end @interface MyClass (SystemDependentMethods) // ... mthod declarations @end So you just put different implemmentation of MyClass (SystemDependentMethods) in different files. _______________________________________________ Discuss-gnustep mailing list [email protected] https://lists.gnu.org/mailman/listinfo/discuss-gnustep
