I have a UITextView called textview and why wont this IBAction work?
What happens is it compiles properly and everything and everything works great until I click the UIButton linked to this IBAction, then the application crashes. I have tried using breakpoints and debugging, I'm not sure what the problem is but I think I have made a syntactical error.
EDIT: From the debugging and breakpoints, the problem is with the two lines of code that have comments appended to them. BTW, I tried those lines of code each individually, and neither of them worked.
EDIT 2: Also, I am able to successfully by using the code
read from the pasteboard, just not write to it.
Code:
- (IBAction) copyToPasteboard{
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.string = textview.text; // I first tried this, and when it didn't work, I tried:
[pasteboard setValue:textview.text forPasteboardType:@"public.utf8-plain-text"]; //this, and this didn't work either.
[pasteboard release];
}
What happens is it compiles properly and everything and everything works great until I click the UIButton linked to this IBAction, then the application crashes. I have tried using breakpoints and debugging, I'm not sure what the problem is but I think I have made a syntactical error.
EDIT: From the debugging and breakpoints, the problem is with the two lines of code that have comments appended to them. BTW, I tried those lines of code each individually, and neither of them worked.
EDIT 2: Also, I am able to successfully by using the code
Code:
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
if ([pasteboard containsPasteboardTypes: [NSArray arrayWithObject:@"public.utf8-plain-text"]]){
//its a string
textview.text = [NSString stringWithFormat:@"%@",pasteboard.string];
}
[pasteboard release];
Last edited: