在 ARC 下,是否可以使用 NSCoding
编码/解码 CGMutablePathRef
(或其非可变形式)?我天真地尝试:
path = CGPathCreateMutable();
...
[aCoder encodeObject:path]
但是我从编译器那里得到了一个友好的错误:
Automatic Reference Counting Issue: Implicit conversion of an Objective-C pointer to 'CGMutablePathRef' (aka 'struct CGPath *') is disallowed with ARC
我该怎么做才能对此进行编码?
最佳答案
NSCoding
是一个协议(protocol)。它的方法只能用于符合 NSCoding
协议(protocol)的对象。 CGPathRef
甚至不是一个对象,所以 NSCoding
方法不会直接工作。这就是您收到该错误的原因。
Here's a guy谁想出了一种序列化 CGPath 的方法。
关于ios - 使用 ARC 编码和解码 CGMutablePathRef,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9938864/