0
-(id)select:(NSString *)original_query
{
    sqlite3_stmt *statement;
    const char * converted = [original_query UTF8String];

    NSLog(@"[INFO] converted char = %@", converted);

    if (sqlite3_prepare_v2(db, converted, -1, &statement, NULL) != SQLITE_OK) {
        @throw [NSException exceptionWithName: @"DB Encriptor" reason: [NSString stringWithFormat: @"Query \"%s\" has failed, we could not execute the SQL statement. '%s'",  converted, sqlite3_errmsg(db) ] userInfo: nil];
    }
    else {
        @try {
             ...
        }
        @catch (NSException * e) {
            NSLog(@"Exception: %@", e);
            return NULL;
        }
    }
}

When the execution reaches the line :

const char * converted = [original_query UTF8String];

I get the following error:

 2013-06-27 02:17:33.505 proof[25200:3c03] -[__NSArrayM UTF8String]: unrecognized selector sent to instance 0xc954a30

This is probably a very simple and silly error, I would appreciate if anyone could give me some guidance, I've spent hours trying different schemas to convert the string to UTF8 but no success so far.

Thanks!

EDIT: Some more information: I am creating a native iOS module to work along Titanium. I call this method from JavaScript (in Titanium) passing a string, something like:

 encriptmydb.select("SELECT count(*) FROM sqlite_master;") 

But the error persists ...

Joseandro Luiz
  • 8,744
  • 4
  • 20
  • 20
  • 8
    I think you are passing NSMutableArray instead of NSString. Please check. – sagarcool89 Jun 27 '13 at 05:32
  • @sagarcool89 is right, from where you are calling `-(id)select:(NSString *)original_query` method – Inder Kumar Rathore Jun 27 '13 at 05:40
  • Please check the message call and the argument passed – Midhun MP Jun 27 '13 at 05:43
  • 2
    Side Note - as pointed out in a now deleted answer, once this is fixed you do need to update the `NSLog` statement to use `%s` instead of `%@` to log `converted`. – rmaddy Jun 27 '13 at 05:45
  • I am creating a native iOS module to work on Titanium. I call this method from JavaScript passing a string, something like: `encriptmydb.select("SELECT count(*) FROM sqlite_master;")` But as you guys can see, the error persists ... Is there a way to convert the NSMutableArray to a NSString? – Joseandro Luiz Jun 27 '13 at 15:03

0 Answers0