I've been using this pattern for some time now
ClassName.h file
@property( readonly ) IBOutlet UIView *someView; // declare readonly
ClassName.m file
// class extension @interface ClassName() @property( readwrite ) IBOutlet UIView *someView; // redeclare readwrite @end
// no @synthesize statements since Xcode 4.3, not needed.
So that the NIB set properties appear to users to be readonly, which I want them to be, but the class itself can set them in code as they are redefined readwrite in a class extension and the NIB loader would find the setSomeView: method and call it or fall back to the underlying _variable (as documented in Accessor Search Implementation Details). That's worked fine thus far.
Now I get the following warning compiling the .m file
"Readonly IBOutlet property when auto-synthesized may not work correctly with 'nib' loader"
Why? What's it not potentially doing now which it was doing before, or potentially wasn't doing before and I was lucky? I find that if I use this pattern and get the warning, I can still put the following
self.someView = someOtherView;
in the body of the .m file and there's no compile warning there, and it works, so there appears to be a mutator auto-synthesized, which the NIB loader would also be able to use surely?
I lastly find that being explicit with @synthesized removes the warning ..
@synthesize someView = _someView;
Why would that make a difference? |