NSArray Question

Discussion in 'iOS Programming' started by jjardim, Jan 9, 2010.

  1. jjardim macrumors newbie

    Mar 19, 2008
    Trying to work with NSMutable array and having trouble -

    here is part of the .h file

    @class AllAnswers;

    @interface StartDeck : UIViewController {

    // Class Object to keep track of the past
    AllAnswers *allanswers;
    NSMutableArray *allanswersArray;


    In the .m file

    allanswers = [[AllAnswers alloc] initWithFirst:temp1 initWithSecond:temp2 initWithThird:temp3 initWithFourth:temp4 initWithTop:randomTopValue initWithBottom:randomBottomValue];

    [allanswersArray addObject:allanswers];
    NSLog(@"temp1 - %i", temp1);
    NSLog(@"Array - %i",[[self allanswersArray] temp1]);
    NSLog(@"Array Count %i", allanswersArray.count);

    The Log Shows
    2010-01-09 11:50:22.464 FlashCards[10024:207] temp1 - 18
    2010-01-09 11:50:22.465 FlashCards[10024:207] Array - 0
    (gdb) continue
    Current language: auto; currently objective-c
    2010-01-09 11:50:25.625 FlashCards[10024:207] Array Count 0

    I would think that the Log in Array - would print out the temp1 variable and the Array Count would return 1.
    I set a break point and it seems nothing is in the array set.

    Any Help would be appreciated.

  2. robbieduncan Moderator emeritus


    Jul 24, 2002
    What do you think this is doing?

    [[self allanswersArray] temp1]
    Also NSArray count returns a NSUInteger. See the U? It means unsigned. Look at the NSLog format specifiers and think very carefully about whether %i is really what you want...

Share This Page