looks like my syntax is wrong. Does not compile

  • Aobject is type of Myobject*

    it has an array for 6 intergers

    Aobject.myArray = [NSArray arrayWithObjects:[NSNumber numberWithInt:
    1], [NSNumber numberWithInt: 2],[NSNumber numberWithInt:3], [NSNumber
    numberWithInt:4], [NSNumber numberWithInt:5],[NSNumber numberWithInt:
    6], nil];

    Now I would like to randomize it.

    for (int j = 0; j < 6; j++)
    {
    NSNumber* aNumber = [Aobject _Edge] numberWithInt:j;
        // looks like my syntax is wrong. Does not compile

    }
  • On 3 Jul 2009, at 21:29, Agha Khan wrote:
    > Aobject is type of Myobject*
    >
    > it has an array for 6 intergers
    >
    > Aobject.myArray = [NSArray arrayWithObjects:[NSNumber numberWithInt:
    > 1], [NSNumber numberWithInt: 2],[NSNumber numberWithInt:3],
    > [NSNumber numberWithInt:4], [NSNumber numberWithInt:5],[NSNumber
    > numberWithInt:6], nil];
    >
    > Now I would like to randomize it.
    >
    > for (int j = 0; j < 6; j++)
    > {
    > NSNumber* aNumber = [Aobject _Edge] numberWithInt:j;
    > // looks like my syntax is wrong. Does not compile
    > }

    Your syntax is indeed incorrect - you may want to review Apple's
    Objective-C documentation [1]. Moreover, it's not clear how this is
    supposed to randomize the array, as no random numbers are involved.

    [1]: http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/
  • On Jul 3, 2009, at 9:29 PM, Agha Khan wrote:

    > NSNumber* aNumber = [Aobject _Edge] numberWithInt:j;
    > // looks like my syntax is wrong. Does not compile

    Objective-C isn't smalltalk.  All message expressions have to be
    enclosed in square brackets:

    NSNumber* aNumber = [[Aobject _Edge] numberWithInt:j];

    -jcr