PDA

View Full Version : Objective-C book activity problem




MorphingDragon
Aug 1, 2009, 05:52 AM
Im going through Cocoa Programming for Mac OS X by Aaron Hillegass and Im having trouble with one of the chapters. In the second chapter there is a number generator that spits out imaginary Lotto numbers but the debugger returns with a bunch of strings and terminates the App. Ive looked through and all the caps etc are correct and Im wondering if it is happening just because Im PPC.


[Session started at 2009-08-01 21:19:40 +1200.]
2009-08-01 21:19:41.160 lottery[8374:10b] *** -[NSPlaceholderString intWithFormat:]: unrecognized selector sent to instance 0x107450
2009-08-01 21:19:41.165 lottery[8374:10b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSPlaceholderString intWithFormat:]: unrecognized selector sent to instance 0x107450'
2009-08-01 21:19:41.168 lottery[8374:10b] Stack: (
2441731472,
2455319788,
2441760600,
2441753940,
2441754600,
11692,
2530131516,
2441428196,
2441429600,
2441626256,
2530221564,
2530560232,
10856,
9928
)

The Debugger has exited due to signal 5 (SIGTRAP).The Debugger has exited due to signal 5 (SIGTRAP).

Youll have to email me to get the project, uploading doesnt seem to work.
morphingdragon@gmail.com

(Im using the latest XCode BTW, 3.1.3. GCC4.2 compiles a heck of a lot faster)



lee1210
Aug 1, 2009, 08:55 AM
Can you just paste the code in a post using CODE tags? Unless your project is thousands of lines, it should be managable.

-Lee

Guiyon
Aug 1, 2009, 11:16 AM
Just taking a quick look at the error, shouldn't you be calling "initWithFormat" instead of "intWithFormat"?

petron
Aug 1, 2009, 03:12 PM
It is the same here:


result = [[NSString alloc] initWithFormat:@"%@ = %d and %d",
[entryDate descriptionWithCalendarFormat:@"%B %A %e %Y"],
firstNumber,
secondNumber];


Take a look what you have in the LotteryEntry.m and change to initWithFormat

/petron

AUFan
Aug 1, 2009, 03:39 PM
You've got a typo. I've made the same mistake myself several times. Petron is right, all you need to do is change the typo from intWithFormat to initWithFormat.