Reading more in the book I found what makes more sense to me in terms of instantiating a class.
My previous post showed this as the way:
MyClass myClassInstance = [[MyClass alloc] init]; |
…effectively calling the alloc and init methods on the class then the class instance, respectively.
I see now you can simply do this:
MyClass myClassInstance = [MyClass new]; |
This makes WAYYY more since coming from ECMA where you’d do:
MyClass myClassInstance = new MyClass(); //java and C# |
var myClassInstance:MyClass = new MyClass(); //as3 |
The author suggests still using the two step approach, alloc/init, so you know you are calling two distinct methods. I will probably use “new” instead because it is more intuitive to me.
On Chapter 4 (Data Types and Expressions) now. More to come.