数据交给UIPasteBoard深拷贝还是浅拷贝? [英] Is data handed over to UIPasteBoard deep copy or shallow copy?

查看:69
本文介绍了数据交给UIPasteBoard深拷贝还是浅拷贝?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果应用在iOS的UIPasteBoard中设置数据,是深拷贝还是浅拷贝?

If an app sets data in the UIPasteBoard of iOS, are they deep copied or shallow copied?

推荐答案

UIPasteboard 使用 NSData 来存储数据.因此,它是深拷贝.

UIPasteboard uses NSData to store the data. Hence, it is deep copy.

来自setData:forPasteboardType:"的官方文档

From the official documentation for "setData:forPasteboardType:"

使用此方法将原始数据放在粘贴板上.例如,您可以归档模型对象图并将生成的 NSData 对象传递给相关应用通过使用自定义粘贴板类型的粘贴板.(要将对象——例如 NSString、NSArray、NSDictionary、NSDate、NSNumber、UIImage 或 NSURL 对象——放在粘贴板上,请使用 setValue:forPasteboardType: 方法.)此方法为粘贴板中的第一项.调用此方法将替换粘贴板中当前的所有项."

"Use this method to put raw data on the pasteboard. For example, you could archive a graph of model objects and pass the resulting NSData object to a related app via a pasteboard using a custom pasteboard type. (To put objects—such as NSString, NSArray, NSDictionary, NSDate, NSNumber, UIImage, or NSURL objects—on the pasteboard, use the setValue:forPasteboardType: method.) This method writes data for the first item in the pasteboard. Calling this method replaces any items currently in the pasteboard."

这篇关于数据交给UIPasteBoard深拷贝还是浅拷贝?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆