Question

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

    NSLog(@"[INFO] converted char = %s", 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've spent hours trying different schemas to convert the string or even a [NSMutableArray description] to UTF8 but no success so far. 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 ...

Était-ce utile?

La solution

look at the sample module guide here https://github.com/appcelerator/titanium_modules

basically what is happening is that the arguments are being passed in as an array, you need to just pull off the first one to get the string parameter

See the parameter passing example here

https://github.com/appcelerator/titanium_modules/blob/master/moddevguide/mobile/ios/Classes/TiModdevguideParametersDemoProxy.m

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top