Category Archives: Tips

Using code comments in Xcode 5.0

Code comments are great! We all know this. However, they could be even better with Xcode 5.0. This post will give brief information on how to write proper code comments, so they will appear in autocomplete popups and Quick Help inspector.

Actually, this comment style is pretty typical. There are several keywords, which should be used. So, let’s check those.
Continue reading

Sending message to nil

Recently, I’ve came across Greg Parker’s post on Sending messages to nil.

This is not actually a new information. It is quite old. However, it was new to me. So, good thing about LLVM compiler is that now even C struct‘s are returned initialized to 0 when you send message to nil.

Here is what returned when you call method on nil instance:

// when you call these methods on nil instance:

-(NSInteger)intMethod;
// any integer return type - will return 0

-(float)floatMethod;
// any float return type - will return 0.0f

-(id)objectMethod;
// any object return type - will return nil

-(CGRect)structMethod;
// any struct return type - will return struct initialized to {0}

So, starting with Xcode 4.2 and LLVM 3.0 it is safe to assume that C struct will be zeroed out when returned from nil instance method.

Check Greg’s post for details on other return types.