Re: Strings mangled on generalPasteboard
Re: Strings mangled on generalPasteboard
- Subject: Re: Strings mangled on generalPasteboard
- From: Jens Alfke <email@hidden>
- Date: Mon, 23 Nov 2009 16:26:46 -0800
On Nov 23, 2009, at 4:16 PM, Kevin Walzer wrote:
> Does this address the problem of only one NSURL being returned?
No. But BTW I looked at your code again and I see why it's failing to get the paths.
> for (NSString *type in types) {
> //string type
> if ([type isEqualToString:NSStringPboardType]) {
> pasteboardvalue = [dragpasteboard stringForType:NSStringPboardType];
> //URL; convert to string
> } else if ([type isEqualToString:NSURLPboardType]) {
> pasteboardvalue = [[NSURL URLFromPasteboard:dragpasteboard] absoluteString];
You're looping over all the types on the drag pasteboard, and every time you stuff your resulting 'pasteboardvalue' string into the general pasteboard. Since each iteration overwrites the result of the previous ones, you only end up handling the last type on the pasteboard. I'm not sure exactly what your code is intending to do, but you need to restructure it somehow.
The thing that tends to make the most sense usually is not to loop but to ask the pasteboard for the data for each type you're interested in, the best type first, and then use the first type you get. So in your case you'd probably ask for filenames first, then URLs, then strings.
—Jens_______________________________________________
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