Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Core data 在core数据中保存带有图像附件的NSMutableAtributed字符串_Core Data_Swift3_Nsmutableattributedstring_Nstextattachment - Fatal编程技术网

Core data 在core数据中保存带有图像附件的NSMutableAtributed字符串

Core data 在core数据中保存带有图像附件的NSMutableAtributed字符串,core-data,swift3,nsmutableattributedstring,nstextattachment,Core Data,Swift3,Nsmutableattributedstring,Nstextattachment,我声明了一个NSMutable属性字符串,并将不同的属性字符串附加到它。这些属性化字符串可能包含作为NSTextattachments的图像 var historyText : NSMutableAttributedString = NSMutableAttributedString(string: "") let imageAttachment = NSTextAttachment() imageAttachment.image = UIImage(named: "some_image") i

我声明了一个NSMutable属性字符串,并将不同的属性字符串附加到它。这些属性化字符串可能包含作为NSTextattachments的图像

var historyText : NSMutableAttributedString = NSMutableAttributedString(string: "")
let imageAttachment = NSTextAttachment()
imageAttachment.image = UIImage(named: "some_image")
imageAttachment.bounds = CGRect(x:0, y:-3.0, width:    (imageAttachment.image?.size.width)!, height:(imageAttachment.image?.size.height)!)
let imageString = NSAttributedString(attachment: imageAttachment)
historyText.append(imageString)
然后,我将该属性文本保存在核心数据中。但是,当我从核心数据检索此属性文本时,imageAttachment.bounds将丢失。 请建议一种保持这些界限的方法。
提前感谢。

您如何将其保存在核心数据中?@sschare我定义了一个类型为“Transformable”的列,使用
[nskeyedArchivedDataWithRootObject:historyText]
&
[nskeyedUnarchiveObjectWithData:Data]
将边界重置为{{0,0},{0,0}}。使用
NSRTFDTextDocumentType
nshtmltexdocumenttype
尝试转换它们时,情况相同。似乎您的解决方案是使用
EnumeratAttribute(\attrName:,在enumerationRange:,options中,使用block:)保存每个图像的边界。
不幸的是,此问题仍然存在。在取消归档时,边界仍然会重置为
{{0,0},{0,0}}