Amazon.com Widgets Copying an object with self
Welcome, Guest. Please login or register.
Did you miss your activation email?
October 23, 2014, 02:22:16 AM
Home Help Search chat Login Register 
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan
                     

+ Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+ Old Stuff
| |-+ Chapter Study
| | |-+ Chapter 18 - Copying Objects
| | | |-+ Copying an object with self
Pages: [1] Go Down
Print
Author Topic: Copying an object with self (Read 979 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:



Login with username, password and session length

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 (c) 2009 classroomM.com. All rights reserved.