| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
1. As noted, enforcement of pure virtual base classes.I still don't see why a protocol doesn't fill this requirement. Just because the compiler doesn't barf, curse and delete your source when you don't implement them properly... Ultimately you can never know for sure whether a class implements the protocol at compile time, because - for example - a subclass might implement methods dynamically at runtime. It's behaviour in not meeting a protocol may be valid in it's particular case. The whole "you must implement this or else" methodology just doesn't fit the ObjC mould.
2. The ability to declare methods protected or private I'm aware it's quite possible to declare private methods as a category within the class' source file so that the selectors are not published to client code. For private methods this is fine since it prevents unwanted code from easily using them, but for protected methods it's a nusiance at best and not doable at worst.I believe there's an implicit var (like 'self') which refers to the calling object... perhaps you could make sure the calling object isKindOfClass or isMemberOfClass, protected and private respectively.
I think you can use private and protected keywards in ObjC++, from what I've seen. In fact, I think I've even seen the keywords in ObjC files. They must
do something, presumably, otherwise those files wouldn't have compiled..
But ultimately, it seems to boil down to: what sort of project are you working on where you don't trust the people around you? If you don't declare the methods in the header, they won't use them, right?
3. The ability to declare static instance vars (instance vars that are part of the class object rather than of any instance of that class). If I've missed this functionality somewhere, please tell me where it is. I generally use globals to emulate it, which I personally feel is bad style.You can declare them as static within the class method they're used. Often you'll have the scenario that you want to establish a single default instance, so you would have a class method to retrieve it, which initializes and returns it's static variable as required. That's just one of many examples.
I don't think globals are as bad in ObjC, as compared to C++, in terms of popular opinion. Indeed, why they are so hated in C++ needs a bit of explaining - what's the difference between a global var and a getter function which returns it's own static var?
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.