Objective-C & ActionScript 3 translation notes
Friday, June 5, 2009, 5:56 am
Filed under: Uncategorized | Tags: actionScript, cocoa touch, comparison, development, iPhone, note to self, objective-c, tips, xcode
Filed under: Uncategorized | Tags: actionScript, cocoa touch, comparison, development, iPhone, note to self, objective-c, tips, xcode
[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…
1 Comment
