Skip to content

Encode and decode between JSON and UIBezierPath objects, following the API conventions of Foundation's NSJSONSerialization class

License

Notifications You must be signed in to change notification settings

illyabusigin/UIBezierPathSerialization

Repository files navigation

UIBezierPathSerialization

Version License Platform

by Illya Busigin

Purpose

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.

Installation

To install UIBezierPathSerialization, just drag the class files into your project. Alternatively, if you're using CocoaPods just specify pod 'UIBezierPathSerialization' in your Podfile.

Usage

Encoding

#import "UIBezierPathSerialization.h"

UIBezierPath *bezierPath = [UIBezierPath bezierPathWithRect:CGRectMake(0, 0, 100, 100)];
NSError *error = nil;
    
NSData *data = [UIBezierPathSerialization dataWithBezierPath:bezierPath options:0 error:&error];

Decoding

#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];

Bugs & Feature Requests

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!

License

UIBezierPathSerialization is available under the MIT license. See the LICENSE file for more info.

About

Encode and decode between JSON and UIBezierPath objects, following the API conventions of Foundation's NSJSONSerialization class

Resources

License

Stars

Watchers

Forks

Packages

No packages published