Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I rely on nil UIView returning CGRectZero for its frame?

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.

like image 884
an0 Avatar asked Apr 07 '12 04:04

an0


1 Answers

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.

like image 50
BJ Homer Avatar answered Oct 28 '22 03:10

BJ Homer