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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:23:31+00:00 2026-06-17T12:23:31+00:00

I have a problem with my Objective C code and an SQLite implementation. The

  • 0

I have a problem with my Objective C code and an SQLite implementation. The error line is NSAsset in the if clause, thats comment out. Here is the code:

-(void) createTable: (NSString *) tableName
         withField1: (NSString *) field1
         withField2: (NSString *) field2
         withField3: (NSString *) field3
         withField4: (NSString *) field4
{
    char *err;
    NSString *sql= [NSString stringWithFormat:
                    @"CREATE TABLE IF NOT EXIST '%@' ( '%@ "
                    "TEXT PRIMARY KEY, '%@' INTEGER, '%@' INTEGER, '%@' TEXT);",
                    tableName, field1, field2, field3, field4];

    if (sqlite3_exec(db, [sql UTF8String], NULL, NULL, &err)
        != SQLITE_OK) {
        sqlite3_close(db);
     //   NSAssert(0, @"Could not create table");
    }else{
        NSLog(@"table create");
    }
}

-(NSString *) filePath{
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES);
    return [[paths objectAtIndex:0]stringByAppendingPathComponent:@"bp.sql"];
}

-(void)openDB{
    if (sqlite3_open([[self filePath] UTF8String], &db) !=SQLITE_OK){
        sqlite3_close(db);
        NSAssert(0, @"Database failed to open");
    }else{
        NSLog(@"Database open");
    }
}

And the error message:

*** Assertion failure in -[MainViewController createTable:withField1:withField2:withField3:withField4:], /Users/Modius/X-Code 4/BPApp/BPApp/MainViewController.m:32
2013-01-18 11:38:07.772 BPApp[58857:c07] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not create table'
*** First throw call stack:
(0x2090012 0x119de7e 0x208fe78 0xc33f35 0x20a0 0x243a 0x1c6817 0x1c6882 0x115a25 0x115dbf 0x115f55 0x11ef67 0xe2fcc 0xe3fab 0xf5315 0xf624b 0xe7cf8 0x1febdf9 0x2013f3f 0x201396f 0x2036734 0x2035f44 0x2035e1b 0xe37da 0xe565c 0x1c3d 0x1b65 0x1)
libc++abi.dylib: terminate called throwing an exception

UPDATE: Here the complete Log Output:

2013-01-18 12:18:14.456 BPApp[59854:c07] Database open
2013-01-18 12:18:14.458 BPApp[59854:c07] *** Assertion failure in -[MainViewController createTable:withField1:withField2:withField3:withField4:], /Users/Modius/X-Code 4/BPApp/BPApp/MainViewController.m:31
2013-01-18 12:18:14.460 BPApp[59854:c07] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not create table'
*** First throw call stack:
(0x2090012 0x119de7e 0x208fe78 0xc33f35 0x20a0 0x243a 0x1c6817 0x1c6882 0x115a25 0x115dbf 0x115f55 0x11ef67 0xe2fcc 0xe3fab 0xf5315 0xf624b 0xe7cf8 0x1febdf9 0x1febad0 0x2005bf5 0x2005962 0x2036bb6 0x2035f44 0x2035e1b 0xe37da 0xe565c 0x1c3d 0x1b65 0x1)
libc++abi.dylib: terminate called throwing an exception
(lldb) 
  • 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-17T12:23:32+00:00Added an answer on June 17, 2026 at 12:23 pm
    NSString *sql= [NSString stringWithFormat:
                    @"CREATE TABLE IF NOT EXIST '%@' ( '%@ "
                    "TEXT PRIMARY KEY, '%@' INTEGER, '%@' INTEGER, '%@' TEXT);",
                    tableName, field1, field2, field3, field4];
    

    Your are missing a single quote after the first field name.

    (Please note that in SQL, table/field names should be quoted with double quotes; SQLite accepts single quotes only for compatibility with MySQL.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I have a bizarre problem with sprintf . Here's my code: void draw_number(int
My problem: I have code in Java that I need to port to Objective-C
I have a problem with some JNI code. I'm getting the following error printed
I have one function in my objective c code that updates a SQLite table
I have a problem with my code. My objective is to fetch some data
I have a peculiar problem. I created a normal Objective C class called SampleTable.
I have an Objective-C audio app based on audio unit and my problem is
I have a problem with some simple code. The photo's, either picked or taken
I have another odd problem with Objective C inheritance. I have a protocol called
I have the following problem in objective C: In a larger context I would

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.