aspose file tools*
The moose likes iOS and the fly likes Retain Vs. Copy Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » iOS
Bookmark "Retain Vs. Copy" Watch "Retain Vs. Copy" New topic
Author

Retain Vs. Copy

Anil Giri
Greenhorn

Joined: Jun 04, 2009
Posts: 9
I am wondering what should we be using, retain or copy with class members? Is copy operation heavier than retain?


SillyCon!
Pratik Goswami
Ranch Hand

Joined: Mar 02, 2009
Posts: 136

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


iOS * Android Developer
 
Don't get me started about those stupid light bulbs.
 
subject: Retain Vs. Copy