Note that there are some explanatory texts on larger screens.

plurals
  1. PODraggable image from class file
    primarykey
    data
    text
    <p>I understand how to make a draggable image, but I am having trouble making an image from a class file be draggable from my main ViewController.m file. My class is called "bomb". Every two seconds, a new bomb is created, and with it a bombImage (an object of bomb). The bomb is added to an NSMutableArray (bombArray).</p> <pre><code>- (void) newBomb { bomb *bomb1 = [[bomb alloc] init]; [bombArray addObject: bomb1]; [bomb1 displayBombOnView:self.view]; //displayBombOnView just makes a new bomb in a random location } </code></pre> <p>I am trying to make it so that the user can drag each "bomb" around. </p> <pre><code>-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event : (bomb *) bomb { UITouch *touch = [[event allTouches] anyObject]; CGPoint location = [touch locationInView:touch.view]; bomb-&gt;bombImage.center = location; } -(void) touchesMoved:(NSSet*)touches withEvent:(UIEvent *)event { bomb *tempBomb = [[bomb alloc] init]; arrayCount = [bombArray count]; for (int k = 0; k&lt;arrayCount; k++) { tempBomb = [bombArray objectAtIndex:k]; CGPoint tappedPt = [[touches anyObject] locationInView: self]; int xPos = tappedPt.x; int yPos = tappedPt.y; if ((xPos &gt;= tempBomb-&gt;bombImage.center.x - 25 &amp;&amp; xPos &lt;= tempBomb-&gt;bombImage.center.x + 25) &amp;&amp; (yPos &gt;= tempBomb-&gt;bombImage.center.y - 25 &amp;&amp; xPos &lt;= tempBomb-&gt;bombImage.center.y + 25)) { [self touchesBegan:touches withEvent:event : [bombArray objectAtIndex:k]]; break; } } } </code></pre> <p>It builds, but then when I try to drag the image, it crashes, saying <code>Thread 1: signal SIGABRT</code>. Any help would be greatly appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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