Question

I'm trying to drag some text (a plain string) from an app.

NSString *text = @"My Text";
NSLog(@"%@", text);

I get "My Text" in the console. Then:

[pboard setPropertyList: text forType: NSStringPboardType];

If I drag this into a text editor (TextWrangler, TextEdit) I get this:

<?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">
<string>My Text</string>
</plist>

What am I doing wrong? How do I just get the plain text out the other end?

Was it helpful?

Solution

It's doing exactly what you asked it to do. It's (helpfully) creating a property list around a basic string you gave it.

You want -setString:forType:.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top