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 6032713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:22:28+00:00 2026-05-23T05:22:28+00:00

I am getting EXC_BAD_ACCESS when I attempt to do anything with the value I’m

  • 0

I am getting EXC_BAD_ACCESS when I attempt to do anything with the value I’m selecting from the local SQLITE database on an iPhone development. The code for my function is

-(void) updateFromDB {

// Setup the database object
sqlite3 *database;

// Open DB
if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {

    NSString *query = [NSString stringWithFormat:@"SELECT MOD_ID FROM MODULE;"];

    //NSLog(@"QUERY: %@",query);

    // Prepare statement
    sqlite3_stmt *statement;
    if(sqlite3_prepare_v2(database, [query UTF8String], -1, &statement, NULL) == SQLITE_OK) {

        // Execute SQL
        while (sqlite3_step(statement) == SQLITE_ROW) {

            // Get MOD_IDs
            NSInteger MOD_ID = sqlite3_column_int(statement, 0);

            NSString *ID = [NSString stringWithFormat:@"%@",MOD_ID];

            //=======================
            // Get Notice Module Data
            //=======================
            if (MOD_ID == 1) {
                self.noticeModule = [[ModuleSetting alloc] initWithID:ID];
            }




        }

    } else {
        NSAssert1(0,@"Error: failed to prepare statement. '%s'", sqlite3_errmsg(database));
    }

    // Release the compiled statement from memory
    sqlite3_finalize(statement);

} else {
    sqlite3_close(database);
    NSAssert1(0,@"Failed to open database. '%s'",sqlite3_errmsg(database));
}
sqlite3_close(database);

}

The bad access occurs on the line

NSString *ID = [NSString stringWithFormat:@"%@",MOD_ID];

Thanks for any help you can offer!

  • 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-05-23T05:22:29+00:00Added an answer on May 23, 2026 at 5:22 am

    %@ denotes objects. But MOD_ID seems to be an integer. So your format should be %d,

    NSString *ID = [NSString stringWithFormat:@"%d", MOD_ID];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code, from which I am getting an EXC_BAD_ACCESS error: -
My iPhone app is crashing and getting EXC_BAD_ACCESS error when using this code: NSError
I keep getting a -> Program received signal: EXC_BAD_ACCESS. In the following code but
I'm trying to select data from the database and I have the following code
I am getting the EXC_BAD_ACCESS error when trying to set a value inside a
I am getting a EXC_BAD_ACCESS (SIGBUS) on this line in my iPhone project: if
I am getting a EXC_BAD_ACCESS on the the glDrawElements() in this code, but only
I'm getting EXC_BAD_ACCESS while parsing XML file in my Xcode4 iPhone app Although I
I am getting EXC_BAD_ACCESS while NSURLREQUEST. I am giving pdf url from server to
I'm getting a EXC_BAD_ACCESS error when this code gets called NSLog(@Count: %@, [fetchedObjects count]);

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.