UIPasteboard 這個就是剪貼板
UIPasteboard * pastboard = [UIPasteboard generalPasteboard];
pastboard.string = self.scanResult;
[LCAlert toastShow:@"掃描結果已復制到剪貼板"];
常用方法:
/*通過名稱獲取粘貼板並且移除*/ + (void)removePasteboardWithName:(NSString *)pasteboardName;
/*從粘貼板中獲取數據,pasteboardType是自定義的,說明app可以處理哪種類型的數據*/ - (nullable NSData *)dataForPasteboardType:(NSString *)pasteboardType;
/*data類型的數據放在粘貼板中,pasteboardType同上*/ - (void)setData:(NSData *)data forPasteboardType:(NSString *)pasteboardType;
/*從粘貼板中取出data*/ - (nullable NSData *)dataForPasteboardType:(NSString *)pasteboardType;