I’m using inputAccessoryView for one of my custom subclasses of UIViewController, which subclasses UIResponder.
The Apple Developer Class Reference for -[UIResponder inputAccessoryView] states:
Subclasses that want to attach custom controls to either a
system-supplied input view (such as the keyboard) or a custom input
view (one you provide in theinputViewproperty) should redeclare [theinputAccessoryView] property asreadwriteand use it to manage their custom accessory
view.
- After redeclaring
inputAccessoryView, must I then@synthesizeit? Doing so seemed to be the only way to get it to compile, but I want to use Apple’sinputAccessoryViewivar, not synthesize my own. - Can I redeclare
inputAccessoryViewasnonatomic? - If I cannot redeclare
inputAccessoryViewasnonatomic, then must I always to accessinputAccessoryViewwithself.inputAccessoryView, i.e., via the property instead of directly accessing the ivar, in order to preserve thread safety?
Yes, you’ll have to provide a setter for the property yourself, unless UIResponder exposes a
setInputAccessoryView:method. If you had access to the underlying ivar, you could just write a setInputAccessoryView: method yourself which sets it. In this case, though, you don’t have access to it, so you’ll have to create one yourself.I don’t think so; this wouldn’t be compatible with the superclass declaration.
I don’t understand why this property is not
nonatomic, since calling (nearly) anything in UIKit from a non-main thread is invalid. In particular, this property is aUIView, and there’s no way for the setter to retain and releaseUIViews on a non-main thread safely.In other words, if the setter is being called from a background thread, the code is broken either way. If it’s only called from the main thread, you can access the ivar directly. So, there’s no reason you can’t access the ivar directly.