-1

I'm trying to copy my "DescriptionLabel" to the Pasteboard. DescriptionLabel is set as a UITextView (I know the name is a little confusing...). Anyway,

- (IBAction)copy:(id)sender {

    UIPasteboard *appPasteBoard = [UIPasteboard generalPasteboard];
    appPasteBoard.persistent = YES;
    [appPasteBoard setString:@"This text is being copied"];
    }

The string in the code is being copied, but I can't manage to get it copying my UITextView/DescriptionLabel. This:

[appPasteBoard setString:_DescriptionLabel];

is not working.

Do any of you have any clue of what I can do to make it work? Been struggling with this for days...

1 Answers1

1

Well, the problem is that you are using setString: to store UITextView, which is an UIKit control and not NSString, in pasteboard. What you probably mean is to store its text value.

Objective-C does not support implicit conversions like Scala or Swift. Solution is simple, just access the text property explicitly:

[appPasteBoard setString:_DescriptionLabel.text];

I encourage you to look into UIPasteboard documentation for details concerning it API: https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIPasteboard_Class/index.html

siejkowski
  • 1,621
  • 12
  • 11