Under ARC, is it possible to encode/decode a CGMutablePathRef
(or its non-mutable form) using NSCoding
? Naively I try:
path = CGPathCreateMutable();
...
[aCoder encodeObject:path]
but I get a friendly error from the compiler:
Automatic Reference Counting Issue: Implicit conversion of an Objective-C pointer to 'CGMutablePathRef' (aka 'struct CGPath *') is disallowed with ARC
What can I do to encode this?
NSCoding
is a protocol. Its methods can only be used with objects that conform to the NSCoding
protocol. a CGPathRef
isn't even an object, so NSCoding
methods won't work directly. That's why you're getting that error.
Here's a guy who has come up with a way to serialize CGPaths.