Re: NSPasteboardItem issues
Re: NSPasteboardItem issues
- Subject: Re: NSPasteboardItem issues
- From: Gordon Apple <email@hidden>
- Date: Wed, 20 Jun 2012 12:49:54 -0500
- Thread-topic: NSPasteboardItem issues
Invariably happens. I hesitate and agonize over whether to hit the ³send²
button, then promptly discover the solution. Apparently, I need to be using
³canReadItemWithDataConformingTpTypes² instead. However, it is still a
mystery to me as to why the other failed.
On 6/20/12 12:28 PM, "Gordon Apple" <email@hidden> wrote:
> I'm trying to convert code to use the new pasteboard methods, and having a few
> issues. For private types, I need to use NSPasteboardItem because the
> read/write protocols don't work for managed objects. (readObjects
> automatically uses NSKeyedUnarchiver and I use a subclass to provide the moc.)
> The following claims success in writing to the general pasteboard, but the
> paste handler is not seeing the NSPasteboardItem. The property list is an
> array of data.
>
> // Copy
> - (void) putShapes:(NSArray*)shapes ontoPasteboard:(NSPasteboard*)pboard {
> [pboard clearContents];
> NSPasteboardItem *pbItem = [[NSPasteboardItem alloc] init];
> [pbItem setPropertyList:[self propListForShapes:shapes]
> forType:RTPShapesType];
> NSArray *objArray = [NSArray arrayWithObject:pbItem];
> BOOL success = [pboard writeObjects:objArray];
> // success = YES;
> }
>
> // Paste
> classArray = [NSArray arrayWithObject:[NSPasteboardItem class]];
> if([pboard canReadObjectForClasses:classArray options:dict]) {
> // This fails. *dict = [NSDictionary dictionary]
>
> Is there anything obvious I'm missing?
>
> Another question -- Dragging in a color chip provides both an NSColor and an
> NSPasteboardItem. Given the first, what use is the latter?
_______________________________________________
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