1 Replies - 1775 Views - Last Post: 23 April 2011 - 12:08 PM

#1 SimonSays  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 34
  • Joined: 06-March 10

Assign, Copy and Retain

Posted 22 April 2011 - 10:05 PM

What are the key differences between these property keywords?

Thanks.
Is This A Good Question/Topic? 0
  • +

Replies To: Assign, Copy and Retain

#2 GWatt  Icon User is offline

  • member icon

Reputation: 276
  • View blog
  • Posts: 3,075
  • Joined: 01-December 05

Re: Assign, Copy and Retain

Posted 23 April 2011 - 12:08 PM

They have to do with how obj-c handles memory management when sending a message to a object. Assign means just put the value of the message into the object's corresponding variable. This is perfect for primitive data types. Retain and copy are for use with other object. Copy will transfer all of the data from the message to the corresponding object. They are now two different instances with the same internal data. Retain just sets the object to point to where message points and increments a reference counter. Incrementing and decrementing the reference counters of an object are done with the retain and release selectors.
Was This Post Helpful? 2
  • +
  • -

Page 1 of 1