objective c - properties - non public weak setter appears to work, but getter only returns the same value as first call -
using properties want publicly visible getter , privately visible setter object weak reference. thought had worked using class extension. until called getter, both, before , after setting object nil. getter worked if called before or after object set nil. here have: bar.h #import <foundation/foundation.h> @interface bar : nsobject @property (nonatomic, readonly, weak) nsobject *object; // note readonly - (id) initwithobject:(nsobject *)object; @end bar.m #import "bar.h" @interface bar () // class extension @property (nonatomic, readwrite, weak) nsobject *object; // note readwrite @end @implementation bar - (id) initwithobject:(nsobject *)object { self = [super init]; if (self) { self.object = object; } return self; } @end main.c #import "bar.h" int main(int argc, char *argv[]) { @autoreleasepool { // call getter once, before setting object nil. // appears work. nsobjec...