4 ms·
Yes! Making a new function in Obj-C is so unnecessarily complicated. I would bet that Obj-C functions are much longer on average than more functional languages.
by rgbrgb 16y ago
Yes! Making a new function in Obj-C is so unnecessarily complicated. I would bet that Obj-C functions are much longer on average than more functional languages. Though header files are great for documentation, most functions one writes should NOT be public but small Lisp-like macros which should not be part of the object's header.
Yes, I know you can make 'private' functions by declaring them at the top of your implementation file. However, this seems like a hack insomuch as you never look at these declarations again until you write another private function - they're just there so your code compiles without warnings.
Here's hoping for Obj-C 3.
- Zev 16y agoSince Objective-C is a superset of C, it also gets compiled in a top-down fashion[1]. if you don't want to add a method to your interface (public or private), just put it above everything else that will use it. 1. I believe there is something about only allowing fir a single pass in the standard, but, don't quote me on it.
- rgbrgb 16y agoYeah, unfortunately you'll get a lot of warnings from Xcode if you do this.
- Zev 16y agoNo you don't. You get warnings about not responding to the method if you put the method implementation after it is used. If it is before, it works fine. Example implementation: @implementation SomeClass - (void) foo { [self baz]; } // a warning will occur; the compiler doesn't know about - baz yet. - (void) bar { [self foo]; } // a warning will not occur; the compiler knows about - foo already. - (void) baz { NSLog(@"bzz"); } // doesn't do anything special @end