explorers' club

explorations in dev, science, sci-fi, games, and other fun stuff!

Objective-C & ActionScript 3 translation notes

4 Comments

[note to self]

Just some things I am learning along the way while teaching myself Objective-C and iPhone development.   Seeing existing code is rather easy to understand in a general sense but the syntax is a tad whacky looking at this point.  I will continue to add to this as I find more translations.

variables:

NSString * someString = @"foo";
=
var someString:String = "foo";

casting:

NSObject *someObject = //pretend I know how to say new();
NSString *castedAsString = (NSString *)someObject;
=
var someObject:Object = {};
var castedAsString:String = String(someObject);

strings:

Strings come in several varieties in Objective-C.  There are NSString, NSMutableString and then the C varient char.  There are probably others I have yet to discover (CSString?).  Since most of what I have seen utilizes NSString, I will stick to that unless otherwise noted.

combining string values

NSString *firstString = @"foo";
NSString *secondString = @"bar";
firstString = [firstString stringByAppendingString:secondString]; //should trace out as "foobar"
=
var firstString:String = "foo";
var secondString:String = "bar";
firstString = firstString + secondString; //wow AS3 is very simple when working with strings

class & instance methods:

+someMethodDefinition = static public function
-someMethodDefinition = public function (instance function)

method calling:

NSString * someString = @"foo";
NSArray * someArray = [someString someNSStringMethodThatReturnsAnArray];
=
var someString:String = "foo";
var someArray:Array = someString.someStringFunctionThatReturnsAnArray();
//kinda made this up since I don't understand method arguments in Objective-C yet.

more to come…

Advertisements

4 thoughts on “Objective-C & ActionScript 3 translation notes

  1. Pingback: Objective-C migration « Iphone SandBox

  2. var firstString:String = “foo”;
    var secondString:String = “bar”;
    firstString = firstString.concat(secondString); //It is more meaningful and effective.
    right?

  3. Pingback: Objective C for the AS3 developer « Andrew’s Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s