by Illya Busigin
- Visit my blog at http://illyabusigin.com/
- Follow @illyabusigin on Twitter
UIBezierPathSerialization
encodes and decodes between JSON and UIBezierPath objects, following the API conventions of Foundation's NSJSONSerialization
class. The output JSON implements a subset of the Path to JSON proposal that allows SVG Paths to be serialized as a normalized JSON object.
To install UIBezierPathSerialization
, just drag the class files into your project. Alternatively, if you're using CocoaPods just specify pod 'UIBezierPathSerialization'
in your Podfile
.
#import "UIBezierPathSerialization.h"
UIBezierPath *bezierPath = [UIBezierPath bezierPathWithRect:CGRectMake(0, 0, 100, 100)];
NSError *error = nil;
NSData *data = [UIBezierPathSerialization dataWithBezierPath:bezierPath options:0 error:&error];
#import "UIBezierPathSerialization.h"
NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"simple_path" ofType:@"json"];
NSData *data = [NSData dataWithContentsOfFile:path];
NSError *error = nil;
UIBezierPath *bezierPath = [UIBezierPathSerialization bezierPathWithData:data options:0 error:&error];
There is no support offered with this component. If you would like a feature or find a bug, please submit a feature request through the GitHub issue tracker.
Pull-requests for bug-fixes and features are welcome!
UIBezierPathSerialization is available under the MIT license. See the LICENSE file for more info.