Stringing me along

Did you know that, when using Objective C over Cocoa, there is no trim method! I’m fooling with some really simple code that should take all of 2 minutes tops but because ObjC/Coca breaks things out completely different than Java I’m facing collisions left and right. Luckily I think I’m smart enough to figure out why:
NSString @someString = @”Start”;
@”Start” == someString;
is not a true statement. I’m relying on my Java background which states that == referrs to object identity not equality is you might hope/guess/pray. Now I’m pawing through the String Programming Guide that sends me off on a tangent. I’m looking at the compare method which returns an NSComparisonResultwhich is typdef’ed to some crazy enum with ordering values. I don’t use enums, not even in Java so now I gotta read up on that too? Where is .equals()? Oh wait… I just looked at the string docs again and there is an isEqualTo method… *phew*

It’s going to take some getting used to. I found the quick API lookup in XCode which is mandatory for writing anything more sophisticated than HelloWorld. There’s a lot of other niceties in XCode as well but, BUT I stand by my original word that XCode has nothing on IntelliJ Idea. There’s an idea! Why doesn’t Jetbrains create an iPhone IDE? That would be off the chains!

2 thoughts on “Stringing me along

  1. Don’t use isEqualTo:, it’s technically an NSComparisonMethods protocol method and is used for scripting support (Obi Wan: “these aren’t the methods you’re looking for”). You should use isEqualToString:, it’s more efficient and it’ll return faster.

  2. Yes, I heed the words of Obi Wan… isEqualToString makes far more sense! Thanx! I’m starting to learn my way around the docs now. I no longer point safari to and drill into the API docs, that’s stoopid. Instead I double click the object I’m curious about to select it, the two-finger tap my track pad (right mouse equivalent) and look it up that way.

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