0

I have written code for an animation that shakes a UIImageView on the screen, but although the syntax seems to be correct, I am getting an obscure "internal compiler error: Bus error: 10" when building. Any idea why?

-(IBAction)shakeCircle{
 int d = 3;
 [UIView animateWithDuration:0.05
 animations:^{myCircle.center = CGPointMake(myCircle.center.x+d, myCircle.center.y-d);}
 completion:^(BOOL finished){
 [UIView animateWithDuration:0.05
 animations:^{myCircle.center = CGPointMake(myCircle.center.x-d, myCircle.center.y+d);}
 completion:^(BOOL finished)
 {
 //but if I comment from here..
 [UIView animateWithDuration:0.05
 animations:^{myCircle.center = CGPointMake(myCircle.center.x+d, myCircle.center.y-d);}
 completion:^(BOOL finished){
 [UIView animateWithDuration:0.05
 animations:^{myCircle.center = CGPointMake(myCircle.center.x-d, myCircle.center.y+d);}
 ];
 }
 ];
 //... to here the code will build.
 }
 ];
 }
 ];
}

Note that if I comment out the last five lines of animation code, everything compiles fine.... What is going on?

I have tried switching to different compilers, that didn't work. I made sure that there's just one myCircle and that the only time it ever gets referred to is when it gets declared, and in that method!

Jonas
130k103 gold badges329 silver badges408 bronze badges
asked Jan 24, 2012 at 13:31
3
  • Is the search function on StackOverflow and/or Google broken? stackoverflow.com/questions/7035640/… Commented Jan 24, 2012 at 13:40
  • Mr Bull, I took a look at similar questions before posting, I think the root of my problem is different. Commented Jan 24, 2012 at 13:53
  • Would be helpful if you edited your question and told people what you have tried... Commented Jan 24, 2012 at 14:03

1 Answer 1

0

Here's a little workaround that solves the problem through recursive calls to the function. Assign to int d the amount by which to shake, then

int d = 3;
-(IBAction)shakeMyCircle{
 [UIView animateWithDuration:0.05
 animations:^{myCircle.center = CGPointMake(myCircle.center.x+3, myCircle.center.y-3);}
 completion:^(BOOL finished){
 [UIView animateWithDuration:0.05
 animations:^{myCircle.center = CGPointMake(myCircle.center.x-3, myCircle.center.y+3);}
 completion:^(BOOL finished) 
 { 
 d--;
 if(d>0) [self shakemyCircle];
 if(d == 0) d = 3;
 }
 ];
 }
 ];
}
answered Jan 25, 2012 at 7:38
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.