Take the 2-minute tour ×

What is the ways/best practices when designing elements on the mac platform in objective-c?

I looking on reading stuff for elements like

  • NSButton
  • NSTextField
  • Gradient backgrounds
  • etc

Should i really subclass all elements and draw it my self (corners, middle area, etc) or could i use some sort of nifty background-image trick.

I have been searching on google on stuff but did not really find anything useful (i might be searching for the wrong thing?)

Any help appreciated, thanks!

share|improve this question

1 Answer 1

up vote 1 down vote accepted

They are different theories, but I personally think subclassing is a good way for that kind of stuff.

Then you can build your application with custom components, which have additional properties, in regard to the built-in ones.

In my point of view, you'll gain a lot by creating generic subclasses, and then subclassing those subclasses with specific code.

You'll then have a kind of derivation. You can then manage backward compatibility more easily, and a change in the generic component class will reflect in all subclasses.

So in my humble opinion, just don't be afraid of subclasses for that kind of stuff.

share|improve this answer
Thank you. I was not really afraid of subclasses those classes, just trying to figure out if there was a simpler/quicker way :-) –  Rasmus Styrk Sep 30 '11 at 18:47
The simpler way may not be the quicker. If you want to build a robust app, think about re-usable components, not quick code... : ) –  Macmade Sep 30 '11 at 18:49
Depending on what you're doing, it may also make sense to subclass one of the parent classes of the things you mentioned, such as NSControl or NSActionCell, and use that as the base class for your custom UI elements. And make sure to read the subclassing notes in the class reference documentation -- not all Apple classes are intended to be subclassed :) –  Alex Martini Sep 30 '11 at 20:19

Your Answer


