Note that there are some explanatory texts on larger screens.

plurals
  1. POObjective-C: Receive "EXC_BAD_ACCESS" signal
    primarykey
    data
    text
    <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/7710903/exc-bad-access-when-trying-to-get-iphone-screen-dimensions">EXC_BAD_ACCESS when trying to get iPhone screen dimensions</a> </p> </blockquote> <p>I have the following code snippet in objective-c that automatically sets some variables to a number of presets. However, on the marked line I get a "Program received signal: EXC_BAD_ACCESS" exception.</p> <p>What confuses me is that the line above is identical, just with a different value. If line 1 does not throw an exception, why should line 2? What can I do about this?</p> <p>Thanks in advance!</p> <p>Sterren</p> <pre><code>- (IBAction)presetPressed:(id)sender { if(self.userEnteringNumber) [self enterPressed]; double xVal; double aVal; double bVal; NSString *preset = [sender currentTitle]; if ([preset isEqualToString:@"1"]) { xVal = 1; aVal = 2; bVal = 3; } else if ([preset isEqualToString:@"2"]) { xVal = 1.5; aVal = 2.9; bVal = 3.0; } else if ([preset isEqualToString:@"3"]) { xVal = -1; aVal = -2; bVal = -3; } [self.variables setValue:[NSNumber numberWithDouble:xVal] forKey:@"x"]; [self.variables setValue:[NSNumber numberWithDouble:aVal] forKey:@"a"]; [self.variables setValue:[NSNumber numberWithDouble:bVal] forKey:@"b"]; self.xVar.text = [NSString stringWithFormat:@"= %@", xVal]; self.aVar.text = [NSString stringWithFormat:@"= %@", aVal]; //EXC_BAD_ACCESS here self.bVar.text = [NSString stringWithFormat:@"= %@", bVal]; [self calculateResult]; } </code></pre>
    singulars
    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.
 

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