the question partially similar existing ones still error memory management.
the following non-arc code work:
[uiview beginanimations:... context:[[nsnumber numberwithint:i] retain]];
and somewhere in didstopselector:
nsnumber * n = (nsnumber *)context; ... [n release];
i tried remove retain/release , add copy (and combined these ways) no effect.
additionally saw similar question:
uiview animation on multiple uiimageviews in arc
they pass imagename
variable context
don't describe if retained or autoreleased.
questions:
1)how convert code arc correctly?
2)is there difference in code if pass retained/autoreleased context (of cousre, if autoreleased work in general)?
try __bridge_retained
retain object , cast void*
void *context = (__bridge_retained void *)( @1000 );
and in animationdidstop
have transfer ownership __bridge_transfer
. @ point arc should naturally release object in current autorelease pool.
- (void)animationdidstop:(void *)context { nsnumber *n = (__bridge_transfer id)context; }
alternatively can switch block based api , reference views directly.
Comments
Post a Comment