UIBezierPath到NSData到服务器到Android [英] UIBezierPath to NSData to Server to Android
问题描述
目前,我有一个符合NSCoding的类,其中包含UIBezierPath和UIColor.
currently I have a class that conforms to NSCoding containing a UIBezierPath and a UIColor.
required init(coder aDecoder: NSCoder) {
super.init()
self.lineColor = aDecoder.decodeObjectForKey("color") as! UIColor
self.bezierPath = aDecoder.decodeObjectForKey("bezier") as! UIBezierPath
}
func encodeWithCoder(aCoder: NSCoder) {
aCoder.encodeObject(lineColor, forKey: "color")
aCoder.encodeObject(bezierPath, forKey: "bezier")
}
我通过NSKeyedArchiver实现了这一目标
I achieve this with NSKeyedArchiver
NSKeyedArchiver.archivedDataWithRootObject(path)
并将其保存在服务器(parse.com)上 我可以使用iOS毫无问题地对其进行存档.但是如何与Android兼容?
and save it on a server (parse.com) I can unarchive it with no problem with iOS. But how to be compatible with Android?
推荐答案
您需要将路径和颜色转换为某种通用格式,然后以通用格式导出.包括RGBA值的SVG之类的东西. UIBezierPath
和密钥归档是具有私有二进制实现的iOS特定项目-尝试在Android上使用它们会花费很长的时间,而不是将来的证明.
You'd need to convert the paths and colours into some common format and export it in a common format. Something like SVG including the RGBA values. UIBezierPath
and keyed archiving are iOS specific items with private binary implementations - trying to work with them on Android will take you a long time and not be future proof.
这篇关于UIBezierPath到NSData到服务器到Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!