Objective-C NSString + Contains

Within C# we have access to a String class from .NET which is full of helpful string manipulation methods. Many other languages have their own forms of a String library and Objective-C is right there with those languages with its NSString class. While NSString is very useful I do find it odd from time to time the naming or usage of certain methods to accomplish tasks. For example, within any .NET based language, such as C#, I have access to a handy method called String.Contains. It’ll return a true or false depending if the the string you pass as a parameter is within, or contained, within the main string object you call this method from.

Continue reading “Objective-C NSString + Contains”

Objective-C Tip: Switch Statements

During one of my sessions of working on the iPhone game. I noticed something very strange within Objective-C.

Continue reading “Objective-C Tip: Switch Statements”

C# and the readonly keyword

I came across something interesting today and thought I’d share this small bit of information to the world. While this made me scratch my head for a second or two it really does make sense. In C#, and I assume VB.NET as well, we have the keyword readonly which allows one to initialize a read only variable during declaration or within a constructor. I recently had the situation where I needed to use a readonly but couldn’t figure out the best area to place it, either in my parent class or in each child class created. Being one who believes less code is better I leaned towards just throwing it in my parent class. It turns out though, that a read only variable can ONLY be initialized during its declaration or in the class the read only variable resides in and children classes WILL NOT be allowed to initialize the variable.

Continue reading “C# and the readonly keyword”