ios - Crash issue in ad-hoc build while drawing -
i'm facing crash issue in following code (only in ad-hoc build).
- (void)drawpreviewinrect:(cgrect)rect { cgcontextref context = uigraphicsgetcurrentcontext(); cgcontextsavegstate(context); cgcolorref strokecolor = [self.delegate.strokecolor cgcolor]; cgfloat strokewidth = self.delegate.strokewidth; cgfloat x = rect.size.width/2.0f; cgfloat y = rect.size.height/2.0f; cgpoint strokepoint = cgpointmake(x, y); cgcontextsetlinecap(context, kcglinecapround); cgcontextsetlinewidth(context, strokewidth); cgcontextsetstrokecolorwithcolor(context, strokecolor); cgcontextmovetopoint(context, strokepoint.x, strokepoint.y); cgcontextaddlinetopoint(context, strokepoint.x, strokepoint.y); cgcontextstrokepath(context); cgcontextrestoregstate(context); }
the crash log shows following picture:
exception type: exc_bad_access (sigsegv) exception codes: kern_invalid_address @ 0x10000008 crashed thread: 0 thread 0 name: dispatch queue: com.apple.main-thread thread 0 crashed: 0 libobjc.a.dylib 0x39f535b0 objc_msgsend + 16 1 coregraphics 0x3237c3ec cgcolorretain + 12 2 coregraphics 0x3237c592 cggstatesetstrokecolor + 38
the code works fine in development environment (on both simulator , device). theories? i'm working under arc.
quick guess: self.delegate
isn't set nil
in init
causes cgcolor
called on random bit of memory.
in more detail: during development builds object variables tend set nice friendly nil
values. when make release build isn't case. crash not being initialised nil
.
it anywhere though; because object variable 'somewhere' pointing random bit of memory.
you can try analyse tool in xcode see if picks on anything. beyond you'll have work backwards object it's crashing through it's parents , check initialised nicely.
Comments
Post a Comment