ios - Check if CGRect null in getter -


i trying check if cgrect null in property getter , if is, load value default, however, in init method, when use property, returns 0 values.

here getter:

- (cgrect)frame {     if(cgrectisnull(_frame))         _frame = cgrectmake(0,0,60,60);     return _frame; }  - (id)init {     self = [super initwithframe:self.frame];     if(self)     {         //do     }     return self; } 

i not sure what's going on , look. appreciated.

when create instance of class, _frame instance variable automatically initialized, before init method called. since _frame c-struct (cgrect), memory cleared zeroes. results in cgrect 0 values.

cgrectnull special, non-zero cgrect. check using cgrectisnull() never true.

using cgrectisempty more proper check this.


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -