I have this piece of code to give my images the color I need:
- (UIImage*)convertToMask: (UIImage *) image { UIGraphicsBeginImageContextWithOptions(image.size, NO, image.scale); CGRect imageRect = CGRectMake(0.0f, 0.0f, image.size.width, image.size.height); CGContextRef ctx = UIGraphicsGetCurrentContext();
Everything works fine in my first view, but when I add this to my detailed view, it gives me this error (it still works):
CGContextSetRGBFillColor: invalid context 0x0. This is a serious mistake. This application or the library it uses uses an invalid context and thereby contributes to a general deterioration in the stability and reliability of the system. This notice is a courtesy: fix this problem. This will be a fatal mistake in the upcoming update.
CGContextFillRects: invalid context 0x0. This is a serious mistake. This application or the library it uses uses an invalid context and thereby contributes to the overall degradation of system stability and reliability. This notice is a courtesy: fix this problem. This will be a fatal mistake in the upcoming update.
Any idea how to get rid of this error?
Thanks.
EDIT:
The action was called with zero for the image. I easily fixed this by adding a condition. Thanks @ipmcc for the comment.
- (UIImage*)convertToMask: (UIImage *) image { if (image != nil) { UIGraphicsBeginImageContextWithOptions(image.size, NO, image.scale); CGRect imageRect = CGRectMake(0.0f, 0.0f, image.size.width, image.size.height); CGContextRef ctx = UIGraphicsGetCurrentContext();
ios objective-c iphone
adam
source share