Re: Newbie Pasteboard question
Re: Newbie Pasteboard question
- Subject: Re: Newbie Pasteboard question
- From: Fritz Anderson <email@hidden>
- Date: Thu, 30 Oct 2003 17:06:21 -0600
On 30 Oct 2003, at 3:07 PM, Bjvrn Carlstrvm wrote:
I use this code to place the items in a plist on the pasteboard
- (BOOL)outlineView:(NSOutlineView *)olv writeItems:(NSArray*)items
toPasteboard:(NSPasteboard*)pboard
{
[pboard declareTypes:[NSArray arrayWithObjects:SCResourceType,
nil]
owner:nil];
NSString* theString = [items description];
[pboard setPropertyList: theString forType: SCResourceType];
return YES;
}
When I retrieve the items after the drag is complete everything works
fine as long as the items doesn't contain any spaces or foreign
(swedish in my case) characters. What is going on? Aren't propertyLists
in unicode? If I retrieve the items as a string every character looks
okay. It's only if I put the plist in a NSArray that my problem occurs.
Given that NSArray is a property-list type, I don't see why you don't
pass it directly in the message to the pasteboard; the
setPropertyList:forType: will serialize it reversibly, wheras the
[NSArray description] string is not a reversible representation.
[pboard setPropertyList: items forType: SCResourceType];
By the way, is there a way to put a reference to an object on the
pasteboard? Would it be safe to assume that the address of an object is
intact after a drag?
You might encode a pointer in a private pasteboard type -- one that
other applications, which have no access to your address space, would
not know to look for. Wrap the address in an NSString or NSData
(NSNumber would be better, but the NSPasteboard documentation avoids
mentioning it, and I don't know if that's intentional, or just a lag in
the documentation). You'll have to take care that you don't deallocate
any object in the course of a drag.
-- F
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.