Search code examples
javajavascriptobjective-cactionscript-3ecma262

translating Ecmascript (Java,javascript,Actionscript) knowledge to Objective C


Newcomer to Objective C and trying to translate concepts and sytax I know from ecmascript based languages to Objective C.

Is it proper to think of the .h header file in ObjectiveC as an Interface in Actionscript?

Lets take the following code example in Objective C which calls a method containing 2 arguments

[myTextObject setString: @"Hello World" color: kWhiteColor];

In Actionscript(or javascript) would this be the same as calling 2 accessor methods on 'myTextObject'? ie

myTextObject.setString("Hello World")
myTextObject.color(kWhiteColor);

Solution

  • Yes, that would be the same. Actually objetive-c also supports the dot syntax in some situations.

    [myTextObject setString:@"Hello World"];

    is the same as

    myTextObject.string = @"hello world";
    

    (objective-c automatically calls the setString method, when you write myTextObject.string = @"something")