Looked for an answer for this question, but I haven\'t found a suitable one yet. I\'m hoping you guys (and gals) can help me out! (This is for an iPhone app)
Alrig
It sounds to me like the common code doesn't need to be in a class at all. Is there a reason you can't just use a C-style function for what you want to do?
You could put the common code in a class and then make your other two classes subclasses of that one; this method also avoids the code duplication.
Another option might be to write a class method instead of instance methods for this common code. I think most people feel that singletons are best avoided as a design choice.
It would be easier to give a good answer if we knew more about what you were really trying to accomplish.
Bear in mind that Objective-C is just a superset of C, and that whilst #include directives are mostly used for header files, there's nothing stopping you using a #include to embed the contents of one implementation inside another implementation. If the code is truly identical, you can easily just stick it in its own file, and #include it in the .m file.
Having said that, perhaps it would be better to use this technique in conjunction with categories, especially if the same implementation has similar behaviours.