Coding CGPathRef

Is it possible to encode CGPathRef variables? I mean, is there an encodeObject: forKey as a method for CGPathRef variables?

+3
source share
3 answers

CGPaths are objects, but I don’t think you can encode them - at least if possible, this is not documented. You will need to create a saved representation of the path yourself and encode it, and then when you decode this representation, reinterpret the path from it yourself.

+1

Github CGPaths NSStrings:

+(nullable NSString*) svgPathFromCGPath:(CGPathRef)aPath;
+(nullable CGPathRef) newCGPathFromSVGPath:(NSString*)anSVGPath whileApplyingTransform:(CGAffineTransform)aTransform;

You can use these lines with NSCoders to store things. Be warned that at any time when you convert between paths and strings, you may lose significant numbers due to conversion.

I wrote these routines, and they are under the MIT license.

0
source

Source: https://habr.com/ru/post/1717758/


All Articles