KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am developing an iOS app with the iOS 5 SDK, Automatic Reference Counting is enabled. But I have a specific object that is being created in large numbers and must be released after a second because otherwise the device will become very slow. It looks like they are not released, as the device is very slow. Is there a way to manually release an object when ARC is enabled? EDIT: My code, this is called 200 times a second to generate sparkles. They fade out after 0.8 seconds so they are useless after then. int xanimationdiff = arc4random() % 30; int yanimationdiff = arc4random() % 30; if (arc4random()%2 == 0) { xanimationdiff = xanimationdiff * -1; } if (arc4random()%2 == 0) { yanimationdiff = yanimationdiff * -1; } Sparkle *newSparkle = [[Sparkle alloc] initWithFrame:CGRectMake(20 + arc4random() % 280, 20, 10, 10)]; //[newSparkle setTransform:CGAffineTransformMakeRotation(arc4random() * (M_PI * 360 / 180))]; //Rotatie instellen (was niet mooi, net sneeuw) [self.view addSubview:newSparkle]; [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.8]; [newSparkle setFrame:CGRectMake(newSparkle.frame.origin.x - xanimationdiff, newSparkle.frame.origin.y - yanimationdiff, newSparkle.frame.size.width, newSparkle.frame.size.height)]; newSparkle.alpha = 0; [UIView commitAnimations]; The sparkle object code: #import "Sparkle.h" @implementation Sparkle - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"sparkle.png"]]]; } return self; } @end
Tags (comma-separated)
Save Edits
Cancel