2
votes

I have some animations in my screen. I am animating all of them through CAlayers using sprite sheets. I am downloading all the assets which sizes to 4 MB in viewDidAppear method.

I am able to show the animations on both simulators and on iPhone. But receiving memory warnings on iPad.

In my device crash reports it is showing exception type as

EXC_BAD_ACCESS(SIGSEGV)

I am animating using the following code:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *getImagePath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.png", imageNameStr]]; UIImage *img = [UIImage imageWithContentsOfFile:getImagePath];

CGImageRef richterImgPl1 = [UIImage imageWithContentsOfFile:getImagePath].CGImage;

NSArray *arrayWithSprites = [img spritesWithSpriteSheetImage:img
                                                  spriteSize:CGSizeMake(230,350)];

CGSize fixedSize = CGSizeMake(230, 350);
MCSpriteLayer *richterPl1 = [MCSpriteLayer layerWithImage:richterImgPl1 sampleSize:fixedSize] ;


richterPl1.frame = imgView.frame;
richterPl1.position = imgView.layer.position;

CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"sampleIndex"];
anim.fromValue = [NSNumber numberWithInt:1];
anim.toValue = [NSNumber numberWithInt:arrayWithSprites.count];
anim.duration = sleepTime;//[imgView.animationImages count] * 0.0500;
anim.repeatCount = 1;

[richterPl1 addAnimation:anim forKey:nil];
[self.view.layer addSublayer:richterPl1];

Any ideas or clues to get rid of this issue?

1
please show some code...Yahia
Try setting exception breakpoint in Xcode. It will show you the exact line which caused the crash.Adam
Try turning on NSZombie objects. Here is how : stackoverflow.com/questions/5386160/…Mats
its a SEGFAULT, do zombies get that?Daij-Djan
@Adam i tried by adding the exception break point but no use.Gani414

1 Answers

0
votes

you have to respond to that didReceiveMemory warning and free some resources or your app will be killed by the os which is this segfault you are getting