Properties for Class and Its Subclasses Only

Jay Haase picture Jay Haase · Nov 24, 2010 · Viewed 13.4k times · Source

Is it possible to define properties that are only available to the class they are defined in, and that class's subclasses?

Stated another way, is there a way to define protected properties?

Answer

Dave DeLong picture Dave DeLong · Nov 24, 2010

Technically, no. Properties are really just methods, and all methods are public. The way we "protect" methods in Objective-C is by not letting other people know about them.

Practically, yes. You can define the properties in a class extension, and still @synthesize them in your main implementation block.