Considering this class :
@interface SampleClass : NSObject {
NSMutableArray *_childs;
}
- (void)addChild:(ChildClass *)child;
- (void)removeChild:(ChildClass *)child;
@end
How can i test when i add a child if the _childs array contains one object without adding a property to access it (because i don’t want allow client code to access the _childs array) ?
Create a
@propertyfor it in the class extension and use the property for all accesses, that way you are testing and using the same code.