国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

ios - Why do some books say that the initialization method and dealloc method should always read and write data through instance variables?
我想大聲告訴你
我想大聲告訴你 2017-05-17 10:05:31
0
1
1142

Effiective objecttive -c2.0 This book says that the initialization method and dealloc method should always read and write data through instance variables. After reading it for a long time, I didn’t understand the reason? Has anyone read this book?

我想大聲告訴你
我想大聲告訴你

reply all(1)
黃舟

Isn’t it very clear in the book:

  • _name = @"Jack" It is fast to directly assign values ??to variables without sending messages through setters.

  • For the following name attributes:

@property (nonatomic, copy) NSString *name;

Direct assignment is: _name = @"Jack"; ,通過 self.name = @"Jack" 其實(shí)等同于 _name = @"Jack".copy;

  • self.name = @"Jack" 會(huì)觸發(fā)KVO,_name = @"Jack" will trigger KVO,

    will not
  • self.name = @"Jack"

    You can perform breakpoint debugging in the setter method, and you will know every assignment.

NSString *str = _name,賦值用 self.name = @"Jack"So there is a reasonable compromise solution, which is to use NSString *str = _name when reading data, and use

when assigning values.

self.name = @"Jack"可能不等同于 _name = @"Jack".copyAnother thing to note is that subclasses may override setter methods, and using

may not be equivalent to _name = @"Jack".copy.

I don’t understand what you are unclear about, so I can only briefly describe it using my ideas. ??
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template