When I use an NSArrayController
with instances of NSManagedObject
, I was under the impression that the following would give me its selected object:
[myArrayController selection]
However, this gives me an instance of some private NS Proxy class.
When I use:
[[myArrayController selectedObjects] objectAt: 0]
...all is fine and I have my instance of NSManagedObject
.
I understand the necessity for these methods as you can probably have lists which allow for multiple selection. I do not understand why selection
does not give me the instance of NSManagedObject
.
It states in the documentation for NSObjectController (which NSArrayController inherits from) that this method returns a proxy object.
You will be able to use any KVC methods on the proxy object, but if you want any class - specific functionality you will have to use the second method in your sample above. As you've stated, this is to return a valid object in cases of no or multiple selection.
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