how to solve ran time error NSString, sqlite3_column_text NULL problem?
Posted
by Ajeet Kumar Yadav
on Stack Overflow
See other posts from Stack Overflow
or by Ajeet Kumar Yadav
Published on 2010-03-09T05:46:59Z
Indexed on
2010/03/09
5:51 UTC
Read the original article
Hit count: 278
iphone
|objective-c
I am new in iphone application developer i am using sqlite3 database and in app delegate i am wright following code and run properly we also find value from database to in my aplication,
but immediately the application is going to crass why this is occurs i am not understand.
code is given bellow
-(void)Data
{
databaseName = @"dataa.sqlite";
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [documentPaths objectAtIndex:0];
databasePath =[documentsDir stringByAppendingPathComponent:databaseName];
[self checkAndCreateDatabase];
list1 = [[NSMutableArray alloc] init];
sqlite3 *database;
if (sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK)
{
if(detailStmt == nil)
{
const char *sql = "Select * from Dataa";
if(sqlite3_prepare_v2(database, sql, -1, &detailStmt, NULL) == SQLITE_OK)
{
//NSLog(@"Hiiiiiii");
//sqlite3_bind_text(detailStmt, 1, [t1 UTF8String], -1, SQLITE_TRANSIENT);
//sqlite3_bind_text(detailStmt, 2, [t2 UTF8String], -2, SQLITE_TRANSIENT);
//sqlite3_bind_int(detailStmt, 3, t3);
while(sqlite3_step(detailStmt) == SQLITE_ROW)
{
//NSLog(@"Helllloooooo");
NSString *item= [NSString stringWithUTF8String:(char *)sqlite3_column_text(detailStmt, 0)];
//NSString *fame= [NSString stringWithUTF8String:(char *)sqlite3_column_text(detailStmt, 1)];
//NSString *cinemax = [NSString stringWithUTF8String:(char *)sqlite3_column_text(detailStmt, 2)];
//NSString *big= [NSString stringWithUTF8String:(char *)sqlite3_column_text(detailStmt, 3)];
//pvr1 = pvr;
item1=item;
//NSLog(@"%@",item1);
data = [[NSMutableArray alloc] init];
list *animal=[[list alloc] initWithName:item1];
// Add the animal object to the animals Array
[list1 addObject:animal];
//[list1 addObject:item];
}
sqlite3_reset(detailStmt);
}
sqlite3_finalize(detailStmt);
// sqlite3_clear_bindings(detailStmt);
}
}
detailStmt = nil;
sqlite3_close(database);
}
when we see console they show the following error giving bellow
2010-03-09 10:02:40.262 SanjeevKapoor[430:20b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[NSString stringWithUTF8String:]: NULL cString'
when we see debugger they show error in following line
NSString *item= [NSString stringWithUTF8String:(char *)sqlite3_column_text(detailStmt, 0)];
I am not able to solve that problum plz help me.
© Stack Overflow or respective owner