IOS读写剪切板 UIPasteboard (备忘)

写剪切板

UIPasteboard* slotPB = [UIPasteboard pasteboardWithName:@"a.com" create:YES];

 [slotPB setData:[NSKeyedArchiver archivedDataWithRootObject:@"hello"] forPasteboardType:@"test"];

读剪切版

UIPasteboard* slotPB = [UIPasteboard pasteboardWithName:@"a.com"  create:YES];

NSString *txt = [NSKeyedUnarchiver unarchiveObjectWithData:[slotPB dataForPasteboardType:@"test"]];

 NSLog(@"%@", txt);


你可能感兴趣的:(IOS读写剪切板 UIPasteboard (备忘))