NSMultipleTextSelectionPboardType not working

  • Hi,

    I'm trying to read some NSMultipleTextSelectionPboardType data off the
    pasteboard:

    NSData* data = [pboard dataForType:NSMultipleTextSelectionPboardType];

    I've verified that the pasteboard is holding the data using -
    [NSPasteboard availableTypeFromArray:], but I'm encountering two
    oddities.  First, I expected the data to be in an NSArchiver format,
    as is the standard for pasteboard data, but it seems to be a property
    list instead.  If I write out the raw data to a file, the actual data
    on the pasteboard looks like this if you dump it to a file:

    > <?xml version="1.0" encoding="UTF-8"?>
    > <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/
    > PropertyList-1.0.dtd">
    > <plist version="1.0">
    > <array>
    > <integer>1</integer>
    > <integer>1</integer>
    > <integer>1</integer>
    > </array>
    > </plist>

    which seems a little bizarre.  (It's not even a binary plist?)

    Second, no matter what text is selected on the pasteboard, the only
    elements in the array for the multiple selection is an NSNumber of 1.
    I get one NSNumber for each selection.  So, if I have the text

    foo bar

    and select the "foo" and "bar" separately, I receive an array of two
    NSNumbers, both of which are 1.  If I have four text selections on the
    pasteboard, no matter what the original text is, I receive an array of
    four NSNumbers, all of which are 1.  I've been using TextEdit and
    Xcode as the source applications for the pasteboard selections, and
    both of them exhibit this behaviour.

    I'm presuming this is a bug in NSTextView (it doesn't write
    NSMultipleTextSelectionPboardType to the paste board properly) and
    that I should file a radar, but I thought I'd double-check to make
    sure I'm not doing anything very silly first.  Googling for
    NSMultipleTextSelectionPboardType turns up nothing helpful.

    Thanks all!

    --
    % Andre Pang : trust.in.love.to.save  <http://www.algorithm.com.au/>
  • On Aug 7, 2008, at 9:06 PM, André Pang wrote:

    > I'm trying to read some NSMultipleTextSelectionPboardType data off
    > the pasteboard:

    You should not do this without reading the AppKit release notes.

    Douglas Davidson
  • On 09/08/2008, at 4:02 AM, Douglas Davidson wrote:

    > On Aug 7, 2008, at 9:06 PM, André Pang wrote:
    >
    >> I'm trying to read some NSMultipleTextSelectionPboardType data off
    >> the pasteboard:
    >
    > You should not do this without reading the AppKit release notes.

    Ah, thanks for the tip Douglas!  I've posted some code to read the
    NSMultipleTextSelectionPboardType data off an NSPasteboard at the
    Cocoadev Wiki:

      http://cocoadev.com/index.pl?NSMultipleTextSelectionPboardType

    Hopefully somebody else will find it useful and it'll pick up some
    Google juice.  (I'll probably update the page later to include some
    code to write the pasteboard data in that format too.)

    --
    % Andre Pang : trust.in.love.to.save  <http://www.algorithm.com.au/>
previous month august 2008 next month
MTWTFSS
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Go to today