Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
September 25, 2017, 04:45:44 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
  Print  
Author Topic: Copying an object with self  (Read 1661 times)
MarkReid
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];

vs.

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.
Logged
skochan
Administrator
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.


Cheers,

Steve Kochan
Logged
Pages: [1]   Go Up
  Print  
 
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 classroomM.com. All rights reserved.