Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7872917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:21:32+00:00 2026-06-03T02:21:32+00:00

Possible Duplicate: EXC_BAD_ACCESS when trying to get iPhone screen dimensions I have the following

  • 0

Possible Duplicate:
EXC_BAD_ACCESS when trying to get iPhone screen dimensions

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.

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?

Thanks in advance!

Sterren

- (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];
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T02:21:35+00:00Added an answer on June 3, 2026 at 2:21 am

    xVal, aVal, bVal are all primitive doubles, but yet your string format is looking for an object via %@.

    try replacing %@ with %f (or %g if you prefer scientific notation):

        self.xVar.text = [NSString stringWithFormat:@"= %f", xVal];
        self.aVar.text = [NSString stringWithFormat:@"= %f", aVal];
        self.bVar.text = [NSString stringWithFormat:@"= %f", bVal];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: C# okay with comparing value types to null Consider the following code
Possible Duplicate: Why do I get a null pointer exception from TabWidget? I have
Possible Duplicate: XPath: How to match attributes that contain a certain string I'm trying
Possible Duplicate: Implicit cast from char** to const char** Given the following code: void
Possible Duplicate: Javascript/PHP and timezones It is possible to get the Olson timezone id
Possible Duplicate: Special characters in PHP / MySQL I have a problem. I have
Possible Duplicate: What is the !! (not not) operator in JavaScript? I have encountered
Possible Duplicate: Android - ListView click HOWTO? to be more specific I have a
Possible Duplicate: Place commas in Javascript integers I have a variable containing a number
Possible Duplicate: PHP get all arguments as array? Within a javascript function arguments always

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.