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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:54:05+00:00 2026-05-13T20:54:05+00:00

I need some help! Please. I am trying to develop a very very simple

  • 0

I need some help! Please. I am trying to develop a very very simple application, basically just a simple book reader. Ideally, the first view would be a uitableview listing the names of chapters, then selecting the row would take you to a detail view that has the chapter which is broken up into segments. Note the segments are actually their own records inside of the table. So I am trying to populate a uitext view with multiple records from a db table. The process of getting all of my data from this db is where I’m just getting all messed up. I searched around on the internet for some tutorials and I found a very useful one here. I went through it step by step, and it made sense, it was all making sense. But instead of using the db he provided, I wanted to try inserting my own db, that has all of the content Id like to have viewable, and it wont work. Its throwing a nice *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[NSString stringWithUTF8String:]: NULL cString' error that I can’t figure out. Does that sound familiar or make sense to anyone? The code for mthe readFromDB method is:

-(void) readTextFromDatabase {
// Setup the database object
sqlite3 *database;

// Init the animals Array
textAr = [[NSMutableArray alloc] init];

// Open the database from the users filessytem
if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
    // Setup the SQL Statement and compile it for faster access
    const char *sqlStatement = "select * from books";//This is where I'm running into trouble
    sqlite3_stmt *compiledStatement;
    if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
        // Loop through the results and add them to the feeds array
        while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
            // Read the data from the result row
            NSString *aChapter = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)];
            NSString *aSection = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 2)];


            // Create a new text object with the data from the database
            Text *text = [[Text alloc] initWithChapter:aChapter Section:aSection];

            // Add the text object to the text Array
            [textAr addObject:text];

            [text release];
        }
    }
    // Release the compiled statement from memory
    sqlite3_finalize(compiledStatement);

}
sqlite3_close(database);

Besides switching the names of some variables, I haven’t changed any part of that code except for the place I mentioned is probably causing some problems. I changed the “select * from animals” statement to “select * from books” where animals was the name of the old table, and books is the name of the table in the new db I would like to use. I thought that wouldn’t be too big of a deal, but apparently it is. I recognize that this is not a very tidy question, but if there is anyone out there that could help me over this wall I am facing, it would be greatly appreciated. Thanks!!!

  • 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-13T20:54:06+00:00Added an answer on May 13, 2026 at 8:54 pm

    I ran into the same issue when using sqlite, I can’t exactly recall when the null strings were coming up (maybe from NULL values in the row), but I used this code to side-step the issue:

    + (NSString*)stringWithCharsIfNotNull: (char*)chars
    {
        if ( chars == NULL )
            return nil;
        else
            return [[NSString stringWithUTF8String: chars] 
                    stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help with jQuery script again :-) Just trying to play with
I am getting a little confused and need some help please. Take these two
I need some help calculating Pi. I am trying to write a python program
I'm working with jQuery for the first time and need some help. I have
Having some issue with Threadpooling here that I need some help with please. I
I'm fairly new to C# programming and need some help. I am trying to
I need some help from the shell-script gurus out there. I have a .txt
I need some help regarding algorithm for randomness. So Problem is. There are 50
I need some help ... I'm a bit (read total) n00b when it comes
Hi I need some help with the following scenario in php. I have a

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.