If a variable:
Then it is appropriate to declare it as an ivar without a corresponding @property
/@synthesize
, and to refer to it directly within the implementation. It is inline with Encapsulation to declare this ivar in the class implementation file.
// MyClass.h
@interface MyClass : ParentClass
@end
// MyClass.m
@implementation MyClass {
NSString *myString;
}
- (void)myMethod {
myString = @"I'm setting my ivar directly";
}
@end
__strong
by the ARC compiler. nil
if it is an object, or 0
if it is a primitive.You can't use KVO and do custom getter and setters with instance variables other than that they are very similar when using ARC.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With