I want to make an instance variable that can't be accessed from outside. Is something like that possible in objective-c? I remember Apple has private variables and stuff like that, but if people know about them, they can use them. Apple calls that "private API", but obviously others can access that stuff if they find out what's in there.
Until now I believed that something like this creates a private instance variable:
@interface MyClass : NSObject {
CGFloat weight;
}
No @property, no @synthesize, just the declaration above.
Also I know Apple adds a _inFrontOfTheirPrivateInstanceVariables, but they said somewhere that they don't like to see others doing that because they might override accidently hidden instance variables when doing that.
What's the trick here?
See Question&Answers more detail:os