Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
June 23, 2018, 07:05:30 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
   Home   Help Search Login Register Chat  
Pages: [1]   Go Down
Author Topic: Copying an object with self  (Read 1802 times)
Full Member
Posts: 173

« on: May 08, 2010, 03:27:26 PM »

Suppose for a moment I have the following code segment -

Code: (Objective-C)
newRect.origin = [origin copy];


Code: (Objective-C)
newRect.origin = [self.origin copy];

What's really the difference between these two? One uses the setter and getter method I think but I don't quite understand what affect that would have on a copy of on object.
Hero Member
Posts: 3114

« Reply #1 on: May 09, 2010, 07:25:50 AM »

The both use the setter.  One sends the copy message directly to the instance variable, the other to the result from the getter method.  There would only be a difference here if the getter that was synthesized did something other than just return the value of the corresponding instance variable.


Steve Kochan
Pages: [1]   Go Up
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents ゥ 2009 All rights reserved.