Re: Dragging NSManagedObject subclass within app
Re: Dragging NSManagedObject subclass within app
- Subject: Re: Dragging NSManagedObject subclass within app
- From: Rick Mann <email@hidden>
- Date: Sun, 10 Mar 2013 20:24:36 -0700
On Mar 10, 2013, at 20:16 , Graham Cox <email@hidden> wrote:
> Yes, just store the pointer somewhere that the source and destination can both access it. You don't even need the pasteboard, except perhaps to put a dummy item on it (I often use an empty string) to keep the drag manager happy. Also use the NSDragOperationPrivate operation mask to stop anyone else trying to interpret your drag.
That's just so ugly, though. The pasteboard should just accept keyed objects, like NSDictionary, precisely for this purpose, especially if you have to put *something* on it.
I tried everything I could think of to do this "right," including putting the NSManagedObject's URL onto the pasteboard, and creating a "Source" protocol that the source implements to allow the destination to get at the MOC for that URL. But then Core Data makes it egregiously difficult to get the NSManagedObject back from the URI.
The note about NSDragOperationPrivate is a good one, though.
> Well, if you over-think the problem, then it can. But intra-app dragging is FAR simpler than extra-app dragging, since the pasteboard doesn't need to come into it.
Except you have to put *something* there, right?
And it seems like there's at least some intent to allow referencing data: NSDragOperationLink.
In the end, I just created an NSData* straight from my object's pointer. I'm about to ARC-ify my code (it was GC), so I'll add bridging retain/release to that, but really, the pboard should allow me to just put retained references onto it.
--
Rick
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden