Objective-C book activity problem

Discussion in 'Mac Programming' started by MorphingDragon, Aug 1, 2009.

  1. MorphingDragon macrumors 603

    MorphingDragon

    Joined:
    Mar 27, 2009
    Location:
    The World Inbetween
    #1
    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)
     
  2. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #2
    Can you just paste the code in a post using CODE tags? Unless your project is thousands of lines, it should be managable.

    -Lee
     
  3. Guiyon macrumors 6502a

    Joined:
    Mar 19, 2008
    Location:
    North Shore, MA
    #3
    Just taking a quick look at the error, shouldn't you be calling "initWithFormat" instead of "intWithFormat"?
     
  4. petron macrumors member

    Joined:
    May 22, 2009
    Location:
    Malmo, Sweden
    #4
    It is the same here:

    Code:
        
    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
     
  5. AUFan macrumors newbie

    Joined:
    Feb 2, 2008
    #5
    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.
     

Share This Page