Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Your code is attempting to call the methods setUpperLimit: setLowerLimit: and setspeed: on the member variable jumpBall1 which you have declared as a UIImageView. However these are not methods of UIImageView - they are setter methods on the @properties you have declared in your own custom JumpBallClass. You have not specified the synthesis of these properties in your implementation file however (using the @synthesize keyword).</p> <p>Perhaps what you mean to do is make the JumpBallClass a subclass of UIImageView and instantiate two instances of this, one for each jumpBall which you would like to control.</p> <pre><code>@interface JumpBallClass : UIImageView { CGPoint center; CGPoint speed; CGPoint lowerLimit; CGPoint upperLimit; IBOutlet UIImageView *jumpBallView; } @property (assign) CGPoint lowerLimit; @property (assign) CGPoint upperLimit; @property (assign) CGPoint speed; @property(nonatomic,retain) UIImageView *jumpBallView; - (void)update; @end @implementation JumpBallClass @synthesize lowerLimit, upperLimit, speed, jumpBallView; - (void)update { center.x += speed.x; center.y += speed.y; if (center.x &gt; upperLimit.x || center.x &lt; lowerLimit.x) { speed.x = -speed.x; } if (center.y &gt; upperLimit.y || center.y &lt; lowerLimit.y) { speed.y = -speed.y; } } @end //assuming jumpBall1&amp;2 have beeen declared like so: //JumpBallClass *jumpBall1=[[JumpBallClass init] alloc]; //JumpBallClass *jumpBall2=[[JumpBallClass init] alloc]; - (void) jumpOnTimer { NSArray * balls = [NSArray arrayWithObjects:jumpBall1, jumpBall2, nil]; [balls makeObjectsPerformSelector:@selector(update)]; } - (void) createPosition { [jumpBall1 setUpperLimit:CGPointMake(60, 211)]; [jumpBall1 setLowerLimit:CGPointMake(0, 82)]; [jumpBall1 setspeed:CGPointMake(2.0,7.0)]; ... } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload