NSStringPboardType gives xml plist not the string I want
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 t开发者_StackOverflowext 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?
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:.
精彩评论