• 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
Re: NSPasteBoard setPropertyList:forType
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSPasteBoard setPropertyList:forType


  • Subject: Re: NSPasteBoard setPropertyList:forType
  • From: Wain <email@hidden>
  • Date: Tue, 13 Dec 2005 21:34:44 +0000

Hi,

Two problems:

1 - you are using 'setPropertyList', this can only be used to set NSData, NSString, NSNumber, NSDate, NSArray, or NSDictionary data to the pboard.
(an NSArray and/or NSDictionary can only contain any of the previously mentioned types and NSData does not allow pointers).

check out http://developer.apple.com/documentation/Cocoa/Reference/ Foundation/ObjC_classic/Classes/NSPropertyListSerialztion.html

2 - you shouldn't try to put pointers on the pboard, it doesn't make sense for outside of the app (and could do horrible things)
and for inside the app you should store the pointer somewhere to get access to it later (or find a different way to get access to
the object without passing a pointer, such as passing an identifier you can use to retrieve the object).

Wain.


On 13 Dec 2005, at 21:06, Stefan Heukamp wrote:

Hi,

since I tried to store a pointer to an instance of one of my objects in a NSPasteboard I'm quite confused about that concept.
For a Drag 'n Drop Operation within my Application I use the NSPasteboard to store a path and a pointer to an object (which represents the data in that path)

Here is an Extract from my source

- (BOOL) outlineView:(NSOutlineView *)outlineView writeItems: (NSArray*)items toPasteboard:(NSPasteboard*)pboard {
[pboard declareTypes : [NSArray arrayWithObjects : NSFilenamesPboardType, @"foo", nil] owner : self];
[pboard setPropertyList:[NSArray arrayWithObjects:[[items objectAtIndex:0] getLocalPath], nil] forType:NSFilenamesPboardType];
BOOL res = [pboard setPropertyList:[NSArray arrayWithObjects: [items objectAtIndex:0], nil] forType:@"foo"];
[pboard types];
NSArray* ar = [pboard propertyListForType:@"foo"];
int i = [ar count];
NSLog(@"result: %i, array: %@, count: %i", res, ar, i);
return YES;
}


The use of the NSFilenamesPboard ist without any problems. If I store e.g. a NSString* in the fooBoard it is also no problem. But if I store that pointer in the fooBoard as done above I get a result YES but if I try reading it out the way I do it above I get a nil-Pointer from NSArray* ar = [pboard propertyListForType:@"foo"];

What am I doning wrong? How do I get that pointer to my outlineView:acceptDrop:item:childIndex function?

Thanks for any advice,

Stefan Heukamp
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40yahoo.co.uk

This email sent to email@hidden



___________________________________________________________ To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
References: 
 >NSPasteBoard setPropertyList:forType (From: Stefan Heukamp <email@hidden>)

  • Prev by Date: Re: Updating System Menu bar
  • Next by Date: componentsSeparatedByString and eol/lf
  • Previous by thread: NSPasteBoard setPropertyList:forType
  • Next by thread: componentsSeparatedByString and eol/lf
  • Index(es):
    • Date
    • Thread