Women in Technology

Hear us Roar



Article:
  The Objective-C Language
Subject:   Question
Date:   2001-05-11 06:13:54
From:   mikebeam
Response to: Question

that's right, you put arguments in the name of the method. Think of it as each argument having a label that is part of the method name. Your java line was correct, although i think you meant to put in a Y before the second location


public void setXLocationYLocation(double x, double y) {}


Full Threads Oldest First

Showing messages 1 through 3 of 3.

  • Question
    2001-05-11 09:19:15  kcrawford [View]

    Thanks, that clears things up a bit.

    Would you call the method with multiple arguments the same way--with the arguments inside the method name?

    For example, would you call the method

    - (void)setXLocation:(double)x yLocation:(double)y

    like this

    [setXLocation:10 yLocation:20];
    • Michael Beam photo Question
      2001-05-11 12:00:20  Michael Beam | O'Reilly Author [View]

      Yeah, that's right, except your method call has no receiver, and it should. So it would have to be

      [anObject setXLocation:10 yLocation:20];

      when you want to invoke it.
      • Question
        2001-05-15 10:06:53  TheBum [View]

        Allow me to step in here with a related question if I may. Are the tags in the argument list of the declaration, e.g. yLocation, just for readability or do they provide a way of specifying arguments in any order?