objective c - Cannot understand getter/setter with object -


it easy understand concept of setter/getter simple data, nsinteger example.

if say: nsinteger a;

the setter "a" changes value of a, , getter gets (returns) value. easy understand atomic/nonantomic concept since atomic guarantee reading "a" when being chnaged return whole value (getter , setter synchronized).

but not understand setter , getter properties pointers objects (nsdata*, nsstring* example). let's example nsmutabledata:

if say: nsmutabledata *m_my_mutable;

imagine have setter setmymutable , getmymutable property belongs object myobject. if this, call getter (since object before appending data):

[[myobject getmymutable] appenddata....]

but appendingdata modify it, sould not seen setter action instead ? or setter refer fact of initiliazing value (which can retained example).

there must missing in concept.

thanks apple92

a setter sets value of property. when set integer property, new integer value stored. when set object property, new object stored. appenddata: not change property — changes the data object itself. atomic property ensure property holds complete value or — doesn't affect object inside property.

incidentally, having mutable state (such nsmutabledata object) that's accessible outside owning object bad idea. once that, becomes way easy have multiple objects trying make own changes , stomping on each other.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -