Top 5 Annoyances in Objective-C

I recently got into iOS programming after purchasing my first iPhone a few months ago (iPhone 4). As a result, I’ve also had to learn to use Xcode and Objective-C. Previously I’d only used Eclipse as my development IDE, since I only really did Java programming on the Mac. As neat as some of Objective-C’s features are, there are several things that bother me when using the language.


5. What’s up with the boolean type keywords? Why do you need YES, TRUE and true? Why not just stick with the standard true and false, instead of adding all these other ones? And they all mean the same thing, of course, because a boolean is a boolean. I guess the thinking behind it is that using YES might make the language feel more “Englishy”, but who knows. Same goes for having bool and BOOL, and nil and NULL. Just pick one and use it.

4. One of the things I disliked about Java was that the file name and the contents of the file had a definite link. If your file is called, the public class inside is required to be named MyFile. With C++, you’re not bound by any such rule and for the most part you aren’t with a Objective-C. Except, if you want to include C++ code in Objective-C, you have to change the file extension.What the hell?

3. Inconsistent/superfluous use of the ‘@’ symbol. Not only is the ‘@’ symbol used to denote an Objective-C String, it’s also prefixed to the interface, property, synthesize, etc keywords. And it’s also to denote the object replacement code for strings (“%@”). Now, I totally get the need for it on the strings, since something has to be used to distinguish between C-strings and Objective-C strings. This makes sense. The use as a replacement tag is also not that bad, and if the language designers had stopped there this item wouldn’t be on the list. But why use it on stuff like interface? In C++ you don’t say @class, and in Java there’s not an @class or @interface keyword. And, if sticking a random character on the front of keywords is so important, why not use the hash (#) sign? That at least shows some consistency. The preferred format would be to just get rid of the damn symbols though.

2. The lack of operator overloading. This kinda goes hand in hand with the next one, but this is definitely something I miss and I’m surprised is missing. There might be some language design reasons why this was not included, I don’t know, but it’s bothersome.

1. And lastly, where the hell is the string concatenation operator? This should be part of every language. I’m used to being able to do something like:

“My number is: ” + mSomeNum + ” and my name is: ” + mMyName;

in Java. Programmers stick strings together quite often, so it makes sense to have something short and sweet. Not to mention the fact that the ‘+’ sign universally translates to “add these things together.” However, in Objective-C we get to do this:

 [NSString stringWithFormat:@”%My number is: %i and my name is: %@”,mSomeNum,mMyName];

It makes understanding the block of code much harder, not to mention requires more typing and more linespace. It sucks a lot, and I cannot think of a good reason for forcing it on developers.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: