Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
November 24, 2017, 10:21:03 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
  Print  
Author Topic: Appendix D and Chapter 19 - AddressCard and AddressBook Classes  (Read 2013 times)
Brian Sanders
Newbie
*
Posts: 2


Email
« on: November 14, 2010, 11:18:00 AM »

Hi Stephen,

I have finished the "Programming in Objective-C" book and have learned a good deal.  I am confused on a couple of topics on Chapter 19 and Appendix D.  The file for the AddressCards appear to be either corrupted or did not decode.  I copied the AddressCard and AddressBook classes word for word out of Appendix D and the following error for the following:

"-(NSMutableArray *) book
{
   return [book [mutableCopy autorelease]]; -> "mutableCopy undefined"
}

-(NSString *) bookName
{
   return [bookName [mutableCopy autorelease]]; -> "mutableCopy undefined"
}"

I am using xCode 3.2.5 and am wondering is this a compiler error or something I have missed in the coding stage.  The AddressBook File looks like this:

"streamtypedŇň—@——— AddressBook
Logged
skochan
Administrator
Hero Member
*****
Posts: 3114



« Reply #1 on: November 14, 2010, 12:20:14 PM »

What code are you using?  The code in the Appendix (C not D, by the way) doesn't match what you've shown (the setters are getters are synthesized there).   Besides, your brackets are in the wrong place,  e.g.,  

Code: (Objective-C)
   return [book [mutableCopy autorelease]];

should be

Code: (Objective-C)
   return [[book mutableCopy] autorelease];

I don't think you'd want the getter to make a new copy of the address book array every time it's called, although that would be a design decision.  Better would be to implement a mutableCopyWithZone:]/tt] method in the class according to the NSMutableCopying protocol if you wanted the ability to make copies of an address book.

Cheers,

Steve
« Last Edit: November 14, 2010, 12:26:32 PM by skochan » Logged
Brian Sanders
Newbie
*
Posts: 2


Email
« Reply #2 on: November 14, 2010, 09:41:58 PM »

Thanks for the reply Stephen.

I am using pages 525-531 of your book "Programming in Objective-C" Copyright 2004 in Appendix D.  The bracket correction cleared up the compiling errors.  I will see if your recommendations will keep the ".arch file from being corrupted.

Thanks,

Brian
Logged
skochan
Administrator
Hero Member
*****
Posts: 3114



« Reply #3 on: November 15, 2010, 08:00:16 AM »

Brian,

That's the first edition, so I can't really speak about that code here.   I haven't looked at it in a while, but the syntax was definitely wrong.

Cheers,

Steve
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.