Question: If you have a property in your public interface like the following

```
@interface MyClass : NSObject
@property(strong) NSString *myProp;
@end

```

And then synthesize it, in effect synthesizing the variable:

```
@implementation MyClass
@synthesize myProp = _myProp; // or just leave it at the default name..
@end

```

What is the visibility of the instance variable `_myProp`? That is, is this considered `@public`, `@protected` or `@private`? I'm guessing since `MySubClass` could inherit from `MyClass` then it would also get the properties (naturally), but would it also inherit the instance variable visibility?

What difference does it make if I put the property in a class extension? That would hide the property from subclasses, and I'm guessing the instance variable, too. Is this documented anywhere?

Answer: 
A synthesized variable acts as if declared `@private`:

```
@interface Garble : NSObject
@property (copy) NSString * s; 
@end
@implementation Garble
@synthesize s;
@end

@interface Bargle : Garble
@end

@implementation Bargle

- (void) useS {
    NSLog(@"%@", s);    // error: instance variable 's' is private
}

@end

```

I swear I've seen this in [the docs](http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ObjectiveC/Chapters/ocProperties.html#//apple_ref/doc/uid/TP30001163-CH17-SW9), but I can't find it right now. Will update if I track it down.
Other classes have access to everything that they `#include`. In other words, to everything that is inside your header.

If something appears only in your implementation file, other classes (including subclasses) don't know it exists. A synthesized property is like that. Other classes know only about the property (a property means a getter and a setter method) but they don't know anything about the inner implementation of its methods.

Note, that the access specifiers (public/private/protected) in obj-c are only a hint to the compiler that even if something appears in the header file, it can't be accessed. The runtime does not check it in any way.

What happens if you put it into a class extension? Note that a property is a set of two methods. You just hide the methods from every class which includes your class main header but not the class extension header.

We use this for example to declare a property as readonly and in class continuation we declare it as readwrite. Then, we can use the setter only from inside of the class.