Pasteboard and property lists
Pasteboard and property lists
- Subject: Pasteboard and property lists
- From: Thomas Lachand-Robert <email@hidden>
- Date: Sat, 5 Jan 2002 16:26:29 +0100
It is possible to put an array in a Pasteboard using setPropertyList? The
doc says so (even though it doesn't define "property list"), but it doesn'
t work for me. For instance, doing that:
- (IBAction) copy:(id)sender {
NSPasteboard* pboard = [NSPasteboard generalPasteboard];
NSArray* items = [self selectedObjectsByCopy:YES];
[pboard declareTypes:FileReferencePboardTypes owner:[FileReference
class]];
/**/ [pboard setPropertyList:items forType:FileReferencePboardType];
/// [pboard set
Data:[items convertToData] forType:FileReferencePboardType]
;
}
- (IBAction) paste:(id)sender {
NSArray* items = nil;
NSPasteboard* pboard = [NSPasteboard generalPasteboard];
if (![pboard availableTypeFromArray:FileReferencePboardTypes]) return;
/**/ items = [pboard propertyListForType:FileReferencePboardType];
/// items = [NSArray arrayWith
Data:[pboard
dataForType:FileReferencePboardType]];
.....
}
doesn't work for me: the returned "items" is an array with zero elements,
whatever the number of elements it did contain in the copy method (no
elements are released here). If I change the line starting with /**/ to
the one commented with ///, it works. (Note that convertToData and
arrayWithData are home-made extensions to NSArray.)
I have also tried to retain the array used in copy, with no result. How do
you guys put arrays in the pasteboard?
Thomas Lachand-Robert
********************** email@hidden
<< Et le chemin est long du projet ` la chose. >> Molihre, Tartuffe.