0

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);
Shog9
  • 156,901
  • 35
  • 231
  • 235
Bachalo
  • 6,965
  • 27
  • 95
  • 189
  • Do yourself a favour and get Stephen Kochan's superb Programming in Objective-C 2.0: http://www.amazon.com/Programming-Objective-C-Stephen-Kochan/dp/0672325861 – Rob Keniger Apr 24 '10 at 21:04
  • Also check out http://www.bit-101.com/blog/?p=1784. An AS3 to iPhone series of tutorials. – Allan Apr 25 '10 at 04:04
  • Thanks for the Stephen Kochan recommendation. have the Apress ObjC book...this would make a good complement. – Bachalo Apr 26 '10 at 01:15

2 Answers2

2

I see it like a function with 2 arguments in actionscript because you not just set some values, you call a method and you use them both. Kind of: set (string, color);

Cristi Băluță
  • 1,295
  • 15
  • 27
0

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")

Sorig
  • 1,200
  • 11
  • 24