Wednesday, 11 September 2013

iOS EXC_BAD_ACCESS drawAtPoint

iOS EXC_BAD_ACCESS drawAtPoint

I occasionally get an exc_bad_access when I call drawAtPoint. Weirdly it
does not always occur, generally after this method is called several
times. What could be the issue?
- (UIImage *)createImage {
NSString *testString = @"Test";
UIFont *font = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]];
CGSize size = CGSizeMake(256, 256);
UIGraphicsBeginImageContextWithOptions(size, NO, 0.0);
[testString drawAtPoint:CGPointMake(0.0, 0.0) withFont:font];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}

No comments:

Post a Comment