Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add instance variables or properties to an XCTestCase?

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?

like image 994
MartinW Avatar asked Oct 23 '25 07:10

MartinW


1 Answers

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
like image 105
trojanfoe Avatar answered Oct 25 '25 22:10

trojanfoe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!