More Objective-C annoyances
Having to put square brackets around object messages is a royal pain in the butt. If you have:
[MyClass alloc]
and then you want to initialize it was well, you have to go back to the start and add an additional open bracket like this:
[[MyClass alloc] init]
In Smalltalk this is simply:
MyClass alloc init
Actually in Smalltalk this is really:
MyClass new
As the method "new" is defined on Object to be:
self new init
Objective-C has this same method defined. The book I'm reading states that it is better to do these operations separately so that you understand that two distinct events are occurring. That is complete and utter crap, of course.
Also, why is the base class NSObject instead of just Object?
Oh, another annoying thing about defining your instance variables in a separate .h file where you define the interface (of which the instance variables are not part of) is that when you reference the instance variables in the .m implementation file, they don't exist in that file! You either have to remember this information or go searching for it. Both options are dumb and result in less productivity. This is why object-oriented languages were developed to replace C. Why make all the same mistakes in the new language?
[MyClass alloc]
and then you want to initialize it was well, you have to go back to the start and add an additional open bracket like this:
[[MyClass alloc] init]
In Smalltalk this is simply:
MyClass alloc init
Actually in Smalltalk this is really:
MyClass new
As the method "new" is defined on Object to be:
self new init
Objective-C has this same method defined. The book I'm reading states that it is better to do these operations separately so that you understand that two distinct events are occurring. That is complete and utter crap, of course.
Also, why is the base class NSObject instead of just Object?
Oh, another annoying thing about defining your instance variables in a separate .h file where you define the interface (of which the instance variables are not part of) is that when you reference the instance variables in the .m implementation file, they don't exist in that file! You either have to remember this information or go searching for it. Both options are dumb and result in less productivity. This is why object-oriented languages were developed to replace C. Why make all the same mistakes in the new language?
