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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:45:08+00:00 2026-05-31T06:45:08+00:00

This is my code: //– check for d/b; create it if it doesn’t exist

  • 0

This is my code:

//--   check for d/b; create it if it doesn't exist
NSString *docsDir;
NSArray *dirPaths;

NSMutableArray *sqliteArray = [NSMutableArray array];
[sqliteArray addObject: @"CREATE TABLE IF NOT EXISTS SiteData (SITE_ID TEXT PRIMARY KEY NOT NULL, STA1 TEXT "
    "TBM TEST, SITE_DESC TEXT, REMARKS TEXT, LOOP_COUNT INTEGER, DATE TEXT)" ];
[sqliteArray addObject: @"INSERT INTO SiteData (SITE_ID, LOOP_COUNT) VALUES('','')"];
[sqliteArray addObject: @"CREATE TABLE Readings (SITE_ID TEXT REFERENCES SiteData, LOOP_NBR TEXT, LOOP_CLOSED BINARY, "
    "SEQ INTEGER, STA TEXT, BS TEXT, FS TEXT, DESC TEXT, SSBS TEXT, SSFS TEXT)" ];
[sqliteArray addObject: @"INSERT INTO Readings (SITE_ID, SEQ) VALUES ('','')"];
[sqliteArray addObject: @"CREATE TABLE EmailAddress (EMAIL_ADDRESS TEXT)"];
[sqliteArray addObject: @"INSERT INTO EmailAddress (EMAIL_ADDRESS) VALUES ('Enter email address here')" ];


//  get the documents directory
dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES);
docsDir = [dirPaths objectAtIndex: 0];

//  build path to the d/b file
databasePath =[[NSString alloc] initWithString: [docsDir stringByAppendingPathComponent: @"r64.sdb"]];
NSFileManager *filemgr = [NSFileManager defaultManager];

if([filemgr fileExistsAtPath:databasePath] == NO)  {
    const char *dbpath = [databasePath UTF8String];
    if(sqlite3_open(dbpath, &dbLevelingData) == SQLITE_OK) {
        char *errMsg;
        int i;

        for(i = 0; i < [sqliteArray count]; i++)  {
        if(sqlite3_exec(dbLevelingData, [sqliteArray objectAtIndex:i] , NULL, NULL, &errMsg) != SQLITE_OK)  
            status.text = @"Failed to create table";
        }

        sqlite3_close(dbLevelingData);
    }
    else 
        status.text = @"Failed to open/create database";
}

On the “if(sqlite3_exe…” statement, I’m getting the following build error:

Implicit conversion of an Objective-C pointer to 'const char *' is disallowed with ARC

Why (I don’t see any ‘const’ char)? and how do I fix it? (note: I copied the basic format from another example… the NSMutableArray does NOT have to be mutable, if that would help things)

  • 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-31T06:45:09+00:00Added an answer on May 31, 2026 at 6:45 am

    According to this page, sqlite3_exec() is defined as such:

    int sqlite3_exec(sqlite3*,const char *, int (*)(void*,int,char**,char**), void *, char **);
    

    However, you are invoking it as:

    int sqlite3_exec(sqlite3 *, id, int(*)(void *)(void *, int, char**, char **), void *, char **);
    

    So, if you change your function call to this:

    sqlite3_exec(dbLevelingData, [[sqliteArray objectAtIndex:i] UTF8String], NULL, NULL, &errMsg)
    

    Your code should work fine (basically, we are converting your NSString into a const char *).

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

Sidebar

Related Questions

This code doesn't work, anyone have any recommendations? Perhaps I did something wrong? Anyone
i have this code: <?php $valid_ext = array(pdf, doc); $args = array( 'post_type' =>
This code separates a string into tokens and stores them in an array of
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
This code i put it in the HTML page for check the file value,
This code in JS gives me a popup saying i think null is a
This code is from Prototype.js . I've looked at probably 20 different tutorials, and
this code always returns 0 in PHP 5.2.5 for microseconds: <?php $dt = new
This code works (C# 3) double d; if(d == (double)(int)d) ...; Is there a
This code always works, even in different browsers: function fooCheck() { alert(internalFoo()); // We

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.