GenerallyHelpfulSoftware / SVGgh

A framework for using SVG artwork in iOS Apps. Includes a UIView and a button class, printing and PDF export.
MIT License
141 stars 37 forks source link

SvgRenderer method asImage application chrash #42

Closed KlemenSpruk closed 3 years ago

KlemenSpruk commented 3 years ago

Hello!

When calling function:

/// Returns an image from svg string /// /// - Parameters: /// - svgString: A svg string to parse /// - size: Maximum size of the image returned /// - shouldScale: When se to true the size will be scaled by the screen scale. Defaults to "true" /// - Returns: An image generated from the string static func image(withSVGString svgString: String, maximumSize size: CGSize, scaleForRetina shouldScale: Bool = true) -> UIImage? { return SVGRenderer(string: svgString).asImage(with: size, andScale: shouldScale ? UIScreen.main.scale : 1.0) } an exception with msg. bellow occurs.

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GHStyle renderIntoContext:withSVGContext:]: unrecognized selector sent to instance 0x283899a00' terminating with uncaught exception of type NSException

Is it possible to somehow use do ( try ... ) catch {...} in swift to catch this exception or is there any other way to ignore error if image cannot be created?

grhowes commented 3 years ago

This is the first I’ve seen of this. What parameters are you using?

bbnatebirkholz commented 3 years ago

Same crash. GHStyle doesn't implement -(void) renderIntoContext:(CGContextRef)quartzContext withSVGContext:(id<SVGContext>)svgContext

grhowes commented 3 years ago

Provided a fix. My apologies for taking so long.