3 ms·
remove the .h/.m split The header/@interface is more there for you than the compiler. That is, you don't have to have the @implementation and the @interface in
by Zev 16y ago
remove the .h/.m split
The header/@interface is more there for you than the compiler. That is, you don't have to have the @implementation and the @interface in separate files. One way is to use the @class declaration to say that the class will exist at run-time and the compiler doesn't have to worry about the lack of a header. Another way is to #import the .m directly.
There are two issues that come up with the first method: A warning when you use the class about it and methods/dot-syntax accessors possibly not existing and problems if you want to subclass a class. There's probably a compiler flag to suppress the warnings for the former problem and class_setSuperclass for the latter. Even if it is deprecated.
For the second method, you'll need to do some trickery to prevent duplicate symbols. Its solvable, but the exact details escapes me at the moment.
Anyway, here's a quick sample project to show the first way in action: http://thisismyinter.net/misc/hn/Lone.zip http://thisismyinter.net/misc/hn/Lone.zip.
If you guessed that its a giant hack either way, you'd be right!
Add namespaces
This is tricker than you'd think, mostly due to the C heritage it has. We'll probably be stuck with class prefixes for a long time. At least they makes classes Googleable.
- thought_alarm 16y ago> One way is to use the @class declaration to say that the > class will exist at run-time and the compiler doesn't have > to worry about the lack of a header. Sure, you could just put "uses NSWindowController;" in your .m file and the compiler would know all about the NSWindowController class and its methods, but what about all the typedefs, defines, functions, and other bits C/C++ heritage that everyday Obj-C code uses? Obj-C has been around for 25+ years, and while the libraries have changed a lot during that time the language can still be implemented essentially as a preprocessor on top of a plain old C/C++ compiler, and I don't think that will ever change. Long live MacRuby, though. I look forward to the day that becomes an official first-class language for OS X development.
- Zev 16y agoI never said it was a good idea[1]. Just that it was possible. But, yes. Long live MacRuby. I can't wait until the day I can use it for iOS applications. 1. From my previous post: If you guessed that its a giant hack either way, you'd be right!