Widgets Copying an object with self
Welcome, Guest. Please login or register.
Did you miss your activation email?
November 30, 2015, 04:34:50 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
Author Topic: Copying an object with self (Read 1189 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:

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 All rights reserved.