Frage

I just learned, that I must declare instance variables and properties in a header file in Objective-C. So now i want to add instance variables to my XCTestCase subclass — but it turns out, XCTestCases come without header files. How do i declare instance variables in my test cases?

War es hilfreich?

Lösung

You don't have to declare them in the header file at all. Instance variables and properties are commonly added within a private category in the implementation file:

@interface MyClass () {
    BOOL _someVar;
}

@property NSString *someOtherVar;

- (void)_aPrivateMethod:(id)something;

@end

@implementation MyClass
...
@end
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top