• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
drag & drop objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: drag & drop objects
      • From: Joe Wildish <email@hidden>
  • Prev by Date: Re: Cocoa and dead-code stripping
  • Next by Date: Re: Cocoa and dead-code stripping
  • Previous by thread: Re: NSTokenFieldCell issues
  • Next by thread: Re: drag & drop objects
  • Index(es):
    • Date
    • Thread