Can I rely on nil UIView returning CGRectZero for its frame?
ios, objective-c
Solution
If you're using recent versions of the LLVM Compiler (Xcode 4.2 or later), then yes, messaging `nil` with a struct-returning method will produce a zero-filled struct. In the case of `CGRect`, that means a rect equal to `CGRectZero`.
Source: Greg Parker, who works at Apple on the ObjC runtime.
Problem
Yes, I saw this: If the method returns a struct, as defined by the Mac OS X ABI Function Call Guide to be returned in registers, then a message sent to nil returns 0.0 for every field in the struct. Other struct data types will not be filled with zeros. I just don't get it.