Is it possible to pass the pointer to an object in a drag and drop operation?
Here is the scenario...
I have an 'NSArray' of custom objects. For arguments sake we'll say this is a list of person objects.
The list is tied to an NSTableView
via an NSArrayController
. The NSTableView
is a drag source and I have an NSView
as a drag destination.
When implementing drag and drop I can easily get the name of the currently selected person(s) from the NSArrayController
as an NSString
in the drag process and pass it to the receiver in the NSView
.
However, I would like to be able to pass a pointer to the person object so the receiver has access to the entire object.
The problem seems to be that the drag operation creates a new instance of a person object and does not make a reference to the selected person object despite implementing the required methods in the person model. As a result I get a person object at the destination, it just isn't populated with the data from the object.
I ideally I want the object pointer because the NSView will make use of the object reference in order that any updates to the object itself are reflected in both the NSView
and the NSTableView
(and everywhere else the object is used).
Is it even possible to use the object reference in a drag and drop operation or do I need to pass some custom reference that is an iVar of the person object and then do a lookup once it arrives at the destination? (This would seem a little archaic to me considering how much object referencing Obj-c has).
I understand that a target could accept a drag operation from outside the application, but specifying the operation as a local operation would account for this would it not?
I've checked the apple docs but still don't seem to be able to find an answer.
Drag and Drop Programming Topics
Any and all help much appreciated.