Note that there are some explanatory texts on larger screens.

plurals
  1. POiPhone App crashes after switching, possibly due to UIImage imageNamed
    primarykey
    data
    text
    <p>Hey guys, this may be an obvious thing, but I can't figure it out.</p> <p>My app moves 10 UIImageViews randomly around the screen, and once an UIImageView hits the corner, it changes its image. The problem is: after switching between apps and going back to mine, the app crashes. </p> <p>The console gives me this message: </p> <pre><code>"App" exited abnormally with signal 10: Bus error </code></pre> <p>The crash log states this: </p> <pre><code>Exception Type: EXC_BAD_ACCESS (SIGBUS) Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000011 Crashed Thread: 0 Dispatch queue: com.apple.main-thread </code></pre> <p>I <strong>think</strong> the problem is due to the fact that I'm using <code>UIImage imageNamed</code>, here is the code:</p> <p>In <em>ViewController.h</em>:</p> <pre><code>UIImage *red; UIImage *green; UIImage *blue; UIImageView *ballOne; UIImageView *ballTwo; UIImageView *ballThree; UIImageView *ballFour; // And declare UIImageView for other balls int clr </code></pre> <p>In <em>ViewController.m</em>:</p> <pre><code>- (void)viewDidLoad { ... red = [UIImage imageNamed: @"redTexture.png"]; green = [UIImage imageNamed: @"greenTexture.png"]; blue = [UIImage imageNamed: @"blueTexture.png"]; ... } - (void)moveAll:(NSTimer *)theTimer{ ... // If UIImageView touches a corner, Do this: clr = arc4random()%3 + 1; switch (clr) { case 1: [ballOne setImage:red]; break; case 2: [ballOne setImage:green]; break; case 3: [ballOne setImage:blue]; break; default: break; } // And do this for the rest of 9 "balls" } </code></pre> <p>Why does my App crash, and how do I solve it?</p> <p>Thanks!</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