Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Retain Vs. Copy

 
Anil Giri
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am wondering what should we be using, retain or copy with class members? Is copy operation heavier than retain?
 
Pratik Goswami
Ranch Hand
Posts: 136
Android Chrome Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Anil,

Anil Giri wrote:I am wondering what should we be using, retain or copy with class members? Is copy operation heavier than retain?

Copy is used generally for NSString. If the string is Mutable then it will be copied else it will be retained. Copy is a Call-By-Reference whereas Retain is Call-By-Value.
For both the case object's retain count will be increment by 1.

Thanks
Pratik Goswami
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic