Inside your category's implementation file, declare another category and call it something like MyCategoryName_Private
, and declare your private properties there. Provide implementations of the -propertyName
and -setPropertyName:
methods using associated objects.
For example, your implementation file might look like this:
#import "SomeClass+MyCategory.h"
#import <objc/runtime.h>
@interface SomeClass (MyCategory_Private)
@property (nonatomic, strong) id somePrivateProperty;
@end
@implementation SomeClass (MyCategory_Private)
static void *AssociationKey;
- (id)somePrivateProperty
{
return objc_getAssociatedObject(self, AssociationKey);
}
- (void)setSomePrivateProperty:(id)arg
{
objc_setAssociatedObject(self, AssociationKey, arg, OBJC_ASSOCIATION_RETAIN);
}
@end
@implementation SomeClass (MyCategory)
// implement your publicly declared category methods
@end