Re: EXC_BAD_ACCESS when calling CGContextDrawLayerInRect
Re: EXC_BAD_ACCESS when calling CGContextDrawLayerInRect
- Subject: Re: EXC_BAD_ACCESS when calling CGContextDrawLayerInRect
- From: David Duncan <email@hidden>
- Date: Mon, 14 Apr 2008 13:01:08 -0700
On Apr 14, 2008, at 12:46 PM, Carter R. Harrison wrote:
I'm getting the reference to the context by using:
CGContextRef context = [[NSGraphicsContext currentContext]
graphicsPort];
in my view's initWithFrame: method.
Which isn't guaranteed to be anything in particular (and could in fact
be NULL).
Based upon what you said, how would you recommend I draw to a
CGLayer prior to the first invocation of drawRect: (at which point I
could initialize a CGContextRef instance variable)?
You can't practically. All you can do is wait for your first -
drawRect:, detect that you haven't created the CGLayer and do so (and
draw to the layer) and then proceed as normal.
Now, if you really just want to record some drawing that you use over
and over and over again, then you can just draw to a bitmap context
and grab an image of that context to draw. It should have very similar
performance characteristics for drawing, but will be easier for the
system to manage (since an image is immutable).
--
David Duncan
Apple DTS Animation and Printing
email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden