UIPastboard - cannot copy text

This code should copy the line into generalPasteboard as an object [[UIPasteboard generalPasteboard]], but this method forces the program to exit.

- (void)copyResultToPasteboard { NSString *message = self.resultTextView.text; [UIPasteboard generalPasteboard].string = message; [message release]; } 

I think this has something to do with the format, seeing that the method works if the message is set to a literal string, but resultTextView.text is just NSString ... I don’t quite understand if anyone can help?

+6
objective-c iphone nsstring uipasteboard
source share
2 answers

Are you sure that resultTextView.text returns a copy of the backup storage, and not the actual NSString* used to store the data? Looking back at Apple's documentation, it seems like it just returns an internal pointer (unretained). Calling this line used by the UITextView class can cause this behavior.

+3
source share

You send -release to an object that you didn’t have (or at least that it doesn’t show up to you from snippit) first -retain , +alloc or went through -copy another object.

+3
source share

All Articles