Array display help

Discussion in 'Mac Programming' started by gizabo, Apr 22, 2009.

  1. gizabo macrumors regular

    Jul 20, 2008
    Hey, I want to display one object in my array. How can I do this? Here is the code I tried using
    	[testLabel setStringValue:@"%@", myList(0)];
    Thanks in advance
  2. aaronw1986 macrumors 68030

    Oct 31, 2006
    What language?
  3. gnasher729 macrumors P6


    Nov 25, 2005
    Get a C book. Lookup what a "comma-expression" is. Then ask yourself why you are passing a comma expression to setStringValue. Then fill in the missing bits in this:

    	NSString* theFormattedString = <what goes here>;
    	[testLabel setStringValue: <and what goes here>];
    And after that, how do you write this in one line (if that is what you prefer)?
  4. lee1210 macrumors 68040


    Jan 10, 2005
    Dallas, TX
    Some other things to consider... what is the type of myList? What does the expression myList(0) return? Is myList a C function? If not, the syntax is not correct. Is it an NS(Mutable)Array? If so, you need to pass a message, not use a C construct like x() or x[].

    Some references:
    C operators
    This table includes [], (), and ,. See which, if any, of these you need in this case. () is also used when invoking a function.

    This should help you fill in one of the blanks in gnasher729's example, and would also help in achieving this in a single line.

    NSControl's setStringValue:
    This should help you figure out what sort of argument should be passed to this method.


Share This Page