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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:35:21+00:00 2026-06-18T02:35:21+00:00

This is the Database field values. Below is the code which I am applying

  • 0

enter image description here
This is the Database field values.

Below is the code which I am applying to fetch data from sqlite database

-(void)readDataFromRestaurantTable
{
    [self openDataBase];

    const char *dbpath = [databasePath UTF8String];

    if (sqlite3_open(dbpath, & database) == SQLITE_OK)
    {
        sqlite3_stmt  *statement = NULL;

        NSString *querySQL = [NSString stringWithFormat: @"SELECT * FROM RestaurantDB"];
        const char *query_stmt = [querySQL UTF8String];

        if (sqlite3_prepare_v2(database, query_stmt, -1, &statement, NULL) == SQLITE_OK) {

            while (sqlite3_step(statement) == SQLITE_ROW)
            {
                strRestaurantName = [[NSString alloc] initWithUTF8String:(const char *) sqlite3_column_text(statement, 1)];
                strRestaurantAddress = [[NSString alloc] initWithUTF8String:(const char *) sqlite3_column_text(statement, 2)];
                strRestaurantPhone = [[NSString alloc] initWithUTF8String:(const char *) sqlite3_column_text(statement, 3)];
                strRestaurantLatitude = [[NSString alloc] initWithUTF8String:(const char *) sqlite3_column_text(statement, 4)];
                strRestaurantLongitude = [[NSString alloc] initWithUTF8String:(const char *) sqlite3_column_text(statement, 5)];

                NSLog(@"strRestaurantName :--> %@",strRestaurantName);
            }
        }
        sqlite3_finalize(statement);
    }
    sqlite3_close(database);
}

In the previous block of code application is not going inside the

if (sqlite3_prepare_v2(database, query_stmt, -1, &statement, NULL) == SQLITE_OK)
{

}

Here it is getting statement = 0x00000000 & I think because of this reason only it is not going into the if block.

Error at the time of crash

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSPlaceholderString initWithUTF8String:]: NULL cString'
First throw call stack:
(0x18dc012 0x12a1e7e 0x18dbdeb 0xcbdce6 0x78e4 0x7bdf 0x2ca817 0x2ca882 0x2ebed9 0x2ebd14 0x2ea1ea 0x2ea06c 0x2ebc57 0x12b5705 0x1ec920 0x1ec8b8 0x40f0b4 0x12b5705 0x1ec920 0x1ec8b8 0x2ad671 0x2adbcf 0x2ad6a6 0x412bb9 0x12b5705 0x1ec920 0x1ec8b8 0x2ad671 0x2adbcf 0x2acd38 0x21c33f 0x21c552 0x1fa3aa 0x1ebcf8 0x1da5df9 0x185ff3f 0x185f96f 0x1882734 0x1881f44 0x1881e1b 0x1da47e3 0x1da4668 0x1e965c 0x2712 0x2645 0x1)
libc++abi.dylib: terminate called throwing an exception

Please guide me where is the actual problem lies.

  • 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-18T02:35:23+00:00Added an answer on June 18, 2026 at 2:35 am

    This is being caused by trying to create a NSString object with a NULL string. It is on one of these lines:

    [[NSString alloc] initWithUTF8String:(const char *) sqlite3_column_text(statement, ...)];
    

    So, before you create a NSString with the results of the sql statement you need to check for NULL like this:

    char *tmp = sqlite3_column_text(statement, 1);
    if (tmp == NULL)
        strRestaurantName = nil;
    else
        strRestaurantName = [[NSString alloc] initWithUTF8String:tmp];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this field from the database which is: DataType: Numeric (7, 3) So
I currently have this code which reads the first field in a database record
I have code which selects data from my database and then sets these selected
I have this code below: while ( $qrystmt->fetch() ) { // data array $dataArray[$dbCourseId]['CourseName']
I have a field called system in my database which looks like this system
This my code I am getting email address from database through ajax and mysql
The code below echoes out an HTML table, populated with values from a MySQL
say i have a nvarchar field in my database that looks like this 1,
In a database, there is a field that saves a closure date. This date
Imagine it like this. There is a field in my database called flags in

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.