I want to create an instance variable that cannot be accessed from outside. Is this possible in objective-c? I remember that Apple has private variables and the like, but if people know about them, they can use them. Apple calls this the “private API,” but obviously others can access this material if they find out what is there.
Until now, I thought that something like this creates a private instance variable:
@interface MyClass : NSObject { CGFloat weight; }
No @property, no @synthesize, only the announcement above.
I also know that Apple adds _inFrontOfTheirPrivateInstanceVariables, but they said somewhere that they don't like it when others do it because they can override randomly hidden instance variables in doing so.
What is the trick here?
visibility private objective-c instance-variables
HelloMoon Aug 11 '09 at 19:40 2009-08-11 19:40
source share