drag & drop objects
drag & drop objects
- Subject: drag & drop objects
- From: Ken Tozier <email@hidden>
- Date: Tue, 3 Jul 2007 09:58:04 -0400
Hi
I'm taking my first serious foray into drag & drop and was wondering
how to drag objects from one view to another. NSPasteboard doesn't
seem to support arbitrary objects with any of its set data methods. I
tried doing the following but it did something bad to the system
necessitating a hard reboot.
NSPasteboard *pboard = [NSPasteboard pasteboardWithName:
NSDragPboard];
NSString *classPBoardType = [NSStringFromClass(self class])
stringByAppendingString: @"PBoardType"];
NSLog(@"pboard: %@, declaring pboard types", pboard);
[pboard declareTypes: [NSArray arrayWithObject: classPBoardType]
owner: self];
NSLog(@"adding drag data: %@ to pboard", dd);
[pboard setData: self forType: classPBoardType]; // <- this is what
messed up the system
I'm guessing that I'll have to write an encodeWithCoder/
decodeWithCoder for custom objects and use [NSKeyedArchiver
archivedDataWithRootObject: self], but I'm not sure if there is a
better way to do this.
Is it necessary to archive objects for drags between two views in the
same window? If not, how do you put such objects on the pasteboard
and how do you define their type?
Thanks for any help
Ken
_______________________________________________
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