私は問題を理解することができません。
- (void)viewDidLoad {
NSString *docsDir;
NSArray *dirPaths;
// Get the documents directory
dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
docsDir = [dirPaths objectAtIndex:0];
// Build the path to the database file
databasePath = [[NSString alloc] initWithString: [docsDir stringByAppendingPathComponent: @"contacts.sqlite"]];
}
- (IBAction) saveData{
sqlite3_stmt *statement;
const char *dbpath = [databasePath UTF8String];
if (sqlite3_open(dbpath, &contactDB) == SQLITE_OK)
{
NSLog(@"enter %@",name.text);
NSString *insertSQL = [NSString stringWithFormat: @"INSERT INTO EMP (name) VALUES (\"%@\")", name.text];
//NSLog(@"enter123 %@",dbpath);
const char *insert_stmt = [insertSQL UTF8String];
sqlite3_prepare_v2(contactDB, insert_stmt, -1, &statement, NULL);
NSLog(@"enter789 ");
if (sqlite3_step(statement) == SQLITE_DONE)
{
NSLog(@"Done success");
/*status.text = @"Contact added";
name.text = @"";
address.text = @"";
phone.text = @"";*/
}
else
{
NSLog(@"fail");
//status.text = @"Failed to add contact";
}
sqlite3_finalize(statement);
sqlite3_close(contactDB);
}
}