0

Im Saving to a unique pasteboard here:

UIPasteboard *pasteboard = [UIPasteboard pasteboardWithName:@"myPasteboard" create:YES];
[pasteboard setPersistent:YES];

//save to unique pasteboard
[pasteboard setString: [NSString stringWithFormat:@"%@",self.myTextFieldHere]];

Trying to read it out here:

UIPasteboard *pasteSaved = [UIPasteboard pasteboardWithName:@"myPasteboard"];

   _myTextFieldHere.text = [pasteSaved string];

My error is "no class method for selector" for my local variable of pastesaved

What ive tried so far

 UIPasteboard *pasteSaved =[[UIPasteboard pasteboardTypes] containsObject:@"myPasteBoard"];

 UIPasteboard *pasteSaved = [UIPasteboard pasteboardWithName:@"myPasteboard"];

 UIPasteboard *pasteSaved = [UIPasteboard pasteboardWithUniqueName:@"myPasteboard"];

 UIPasteboard *pasteSaved = [UIPasteboard: @"myPasteboard"];

 UIPasteboard *pasteSaved = [UIPasteboard pasteboardWithUniqueName];  
4

2 回答 2

0

创建独特的粘贴板后,使用以下addItems:方法将项目粘贴到其中:

[pasteboard addItems:@[ @"my_string_for_pasting" ]];

或者,

[[UIPasteboard pasteboardWithUniqueName:@"myPasteboard"] addItems:@[ @"my_string_for_pasting"];

编辑:

从粘贴板中读取:

NSString *copiedString = [[UIPasteboard pasteboardWithUniqueName:@"myPasteboard"] valueForPasteboardType:kUTTypePlainText];
于 2013-10-26T13:08:18.173 回答
0

解决它

如果您创建粘贴板或从它接收使用,则它看起来比使用应用程序特定粘贴板时需要添加create YES or No

复制到粘贴板

UIPasteboard *pasteboard = [UIPasteboard pasteboardWithName:@"myPasteboard" create:YES];
[pasteboard setPersistent:YES];

//save to unique pasteboard
[pasteboard setString: [NSString stringWithFormat:@"%@",self.myTextFieldHere]];

从粘贴板粘贴

 UIPasteboard *pasteboard = [UIPasteboard pasteboardWithName:@"ICPatEditionPasteboard" create:NO];

   self.myTextFieldHere.text = [pasteboard string];
于 2013-10-26T14:54:38.393 回答