I am learning object-c by reading a book. When I read the chapter about class extension, the book gives the following example code:
// A class extension
@int
Think contexts, any other class can access the properties declared at the extensions or any categories as far as the extended interfaces are "visible" at the given context.
For example, the following implementation file contains implementation of two interfaces: BaseObject and BaseObjectController. At the implementation of the other class (BaseObjectController) you can safely use the "hidden" property via getters and setters because the declaration interface is "visible". If you move the implementation of BaseObjectController to another file that can't see declaration of the extension - this code won't compile.
#import "BaseObject.h"
#import "BaseObjectController.h"
// BaseObject
@interface BaseObject()
@property (strong) NSString * idString;
@end
@implementation BaseObject
@end
// BaseObjectController
@implementation BaseObjectController
- (void) initBaseObject {
BaseObject * bo = [BaseObject new];
bo.idString = @"01234";
}
@end