Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
April 26, 2018, 03:50:37 PM *
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: Exercise 1 of Chapter 18  (Read 1831 times)
Full Member
Posts: 173

« on: May 07, 2010, 03:10:39 PM »

So far I've got an address book with four cards ok. I can also copy the AddressBook name without any problems. The question I have however is when it comes to the array should I be looking to make a mutable copy? Am I really just looking to create a copy of the address book as it exists or create a new address book that can have items added to it and removed from it?

As this section of the book only covers shallow copying besides writing my own method am I right that all I'm supposed to be doing it creating a shallow copy of the address book?

Hero Member
Posts: 3114

« Reply #1 on: May 07, 2010, 04:07:21 PM »


Well, as the exercise asks, does it make sense to have a mutable copy method for your AddressBook class?  You might want to make an immutable copy of your AddressBook, say for a backup.   A mutable copy would be useful if you wanted to make changes to it.   As you've noted, these will typically be shallow copies if you follow the way the Foundation copy methods are implemented.  However, as the designer of the class, you get to decide how you want to implement your copies.

Here's a good discussion you may want to look at:


Steve Kochan
Full Member
Posts: 173

« Reply #2 on: May 08, 2010, 02:09:14 PM »

Thanks Steve, posted my attempt at it here. Would appreciate any feedback on it you may have. -

Still not sure I understand it after coding it but I think copying objects when trying to do a deep copy takes more practice. Although from what I read archiving to memory and putting it back into another object using NSData seems more the way to go, is that common practice for a deep copy?

Thanks again.
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.