user1082474
user1082474

Reputation: 119

CGPath as a string

Is there any way to get at the actual data of a CGPath, so it can be saved to a file and restored later?

And is there any documentation on how that data is structured?

I would like to write it as a string (like a SVG path string), or some way with the dictionary object and PList XML files, but I'll take what I can get!

Upvotes: 6

Views: 1590

Answers (1)

Sergey Kalinichenko
Sergey Kalinichenko

Reputation: 726579

There is a post about saving CGPathRefs here. The guy is using CGPathApply function to enumerate through the elements of the path:

static void saveApplier(void* info, const CGPathElement* element) {
    ...
}

...

NSMutableArray* a = [NSMutableArray arrayWithObject:[NSNumber numberWithBool:YES]];
CGPathApply(path, a, saveApplier);

Upvotes: 3

Related Questions