Re: NSPasteboard: writing non-existent filename
Re: NSPasteboard: writing non-existent filename
- Subject: Re: NSPasteboard: writing non-existent filename
- From: Bill Bumgarner <email@hidden>
- Date: Mon, 29 May 2006 08:40:46 -0700
On May 29, 2006, at 8:30 AM, Karim Morsy wrote:
the type I declare for the PasteBoard is NSFilesnamePboardType.
when I write the string (path) of a file to the pasteboard, I add
encoded information for the receiver view of the drag & drop
operation in a prepended string (the view then parses the string,
obtains the info and returns the correct file name).
so for example instead of writing @"/tmp/someFile" to the
pasteboard I do @"/***someInfo***/tmp/someFile".
I'm getting an error message in the run log: "can't create
FSRef ....".
apart from this, things work as desired. So I was wondering, if
it's just that error message that's displayed or if this can cause
a crash ?
If you are writing something to a pasteboard of type
NSFilesnamePboardType that does not match the specification of an
NSFilesnamePboardType, then you shouldn't be using a pasteboard of
type NSFilesnamePboardType!
Consider what happens if you try to drag said pasteboard into the
Finder. It'll think it can handle the pasteboard contents because it
is of a known type, but will fail to understand said contents because
they do not follow any of the patterns perpetuated by
NSFilesnamePboardType.
Use a private pasteboard type. That is, something like....
NSString *MyFancyFilenamePboardType = @"My Super Fancy Private
Pasteboard Type";
pboard = [NSPasteboard pasteboardWithName: NSDragPboard];
[pboard declareTypes: [NSArray arrayWithObjects:
MyFancyFilenamePboardType, NSFilesnamePboardType, nil] owner: self];
[pboard setData: mySuperAugmentedFilenameStuff forType:
MyFancyFilenamePboardType];
[pboard setData: someRegularOldPathsLikeFinderWants forType:
NSFilesnamePboardType];
.....
End result? You'll have your special sauced pasteboard available to
your app(s) but your app will also produce pasteboards that make the
Finder happy.
b.bum
_______________________________________________
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