更新时间:2023-11-28 22:59:10
您是否只想将字符串保存到磁盘?我会使用NSCoding。
Do you just want to save the string to the disk? I would use NSCoding for that.
将对象写入文件:
result = [NSKeyedArchiver archiveRootObject:attributedString toFile:archivePath];
从文件中读取对象:
attributedString = [NSKeyedUnarchiver unarchiveObjectWithFile:archivePath];
您可以使用符合NSCoding的任何对象执行此操作,并且可以非常轻松地添加对NSCoding到您自己的课程。有关更多信息,请访问:
You can do this with any object conforming to "NSCoding", and it's fairly easy to add support for NSCoding to your own classes. More information can be found at: