Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
November 25, 2017, 04:22:48 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: Throwing an Exception in Example 19.7  (Read 2436 times)
Semaj
Newbie
*
Posts: 8


« on: April 28, 2011, 06:07:45 PM »

I get the following exception when running the main in example 19.7:

2011-04-28 17:53:53.498 prog19_7[745:a0f] ================= Contents of: Semaj's address book: ====================
2011-04-28 17:53:53.501 prog19_7[745:a0f] -[NSCFString countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x10010dc60
2011-04-28 17:53:53.502 prog19_7[745:a0f] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x10010dc60'
*** Call stack at first throw:
(
   0   CoreFoundation                      0x00007fff8061c7b4 __exceptionPreprocess + 180
   1   libobjc.A.dylib                     0x00007fff80a9e0f3 objc_exception_throw + 45
   2   CoreFoundation                      0x00007fff80676110 +[NSObject(NSObject) doesNotRecognizeSelector:] + 0
   3   CoreFoundation                      0x00007fff805ee91f ___forwarding___ + 751
   4   CoreFoundation                      0x00007fff805eaa68 _CF_forwarding_prep_0 + 232
   5   prog19_7                            0x0000000100000d85 -[AddressBook list] + 170
   6   prog19_7                            0x0000000100000b52 main + 118
   7   prog19_7                            0x0000000100000ad4 start + 52
   8   ??                               0x0000000000000001 0x0 + 1
)


The program doesn't seem to like my list method.  However, I am able to successfully execute the list method in other examples.  I added it to example 19.6 and it ran without problem. 

Here's the list method from the AddressBook Class:

Quote
-(void) list
{
   NSLog(@"================= Contents of: %@ ====================", bookName);   
   for (AddressCard *theCard in book)
      NSLog(@"%-20s      %-32s", [theCard.name UTF8String],[theCard.email UTF8String]);
   NSLog(@"======================================================", bookName);
}




Any idea on what is causing the problem?
Logged
skochan
Administrator
Hero Member
*****
Posts: 3114



« Reply #1 on: May 02, 2011, 09:14:14 AM »

From the error it appears that you're trying to enumerate an  NSString object and not an array.  Check your initWithCoder: method from your AddressBook class.

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.