One of the easiest mind boggling errors to run into when developing for the iPhone is the accidental override of NSObject's description method. For those who are new to iPhone Development or Objective-C, the description method is equivalent to the more common toString method found in other languages. This is the method that is invoked when an object is printed to a string with %@ string formatting token.
You will encounter the *nil description* output if your description override returns a nil string. While overriding the description method can be useful in allowing developers to describe their object's contents, it also can cause confusing and unexpected output if the override was unintentional.
...now wouldn't it be nice if obj-c required developers to mark methods as override to ensure that all overrides were intentional?
0 comments:
Post a Comment