I was reading through an Objective-C book at the same time I was reading a "Good Coding Preactices"/Design book and I noticed how badly designed (I Think) Cocoa is.

My biggest issue is it's seemingly unpolymorphic design.

For instants, like many other objects, the UIButton class's style is defined using this enum:

typedef enum {
   UIButtonTypeCustom = 0,
   UIButtonTypeRoundedRect,
   UIButtonTypeDetailDisclosure,
   UIButtonTypeInfoLight,
   UIButtonTypeInfoDark,
   UIButtonTypeContactAdd,
} UIButtonType;

Why arn't these just subclasses? It feels like they are making four or five classes into one. I can only imagine that the code is full of switch statements, constantly checking which enum it is. It's impossbile to create your own style. You have to select the first style and then change the properties of the button from there.

Is there a good reason for this? Are there other examples of bad programming in iOS design?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.