Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This solution works for me</p> <p>I have add this code to databaseFlipsideViewController</p> <pre><code>//databaseFlipsideViewController.m - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString:@"showDetail"]) { NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; detailController = segue.destinationViewController; detailController.customerName = [keys objectAtIndex:indexPath.row]; NSLog(@"%@", detailController.customerName); } } </code></pre> <p>And my detailViewController code is this:</p> <pre><code>@implementation detailViewController @synthesize customerLabel,code1Label,code2Label,dateLabel,customerName,code1Name; //file path to database -(NSString*)filePath { NSArray*paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); return [[paths objectAtIndex:0]stringByAppendingPathComponent:@"bp.sql"]; } //open database -(void)openDB { if(sqlite3_open([[self filePath]UTF8String], &amp;db) !=SQLITE_OK) { sqlite3_close(db); NSAssert(0, @"Databese failed to open"); } else { NSLog(@"database opemed"); } } - (IBAction)back:(id)sender { [self.delegate detailViewControllerDidFinish:self]; } - (void)viewDidLoad { [self openDB]; NSString*sql = [NSString stringWithFormat:@"SELECT theDate, customer,code1,code2 FROM summary WHERE key=\"%@\"", customerName]; const char *query_stmt = [sql UTF8String]; sqlite3_stmt*statement; if (sqlite3_prepare_v2(db, query_stmt, -1, &amp;statement, nil)==SQLITE_OK) { if (sqlite3_step(statement)==SQLITE_ROW) { NSString *date = [[NSString alloc] initWithUTF8String:(const char *) sqlite3_column_text(statement, 0)]; dateLabel.text = date; NSString *customer = [[NSString alloc] initWithUTF8String:(const char *) sqlite3_column_text(statement, 1)]; customerLabel.text = customer; NSString *code1 = [[NSString alloc] initWithUTF8String:(const char *) sqlite3_column_text(statement, 2)]; code1Label.text = code1; NSString *code2 = [[NSString alloc] initWithUTF8String:(const char *) sqlite3_column_text(statement,3)]; code2Label.text = code2; } sqlite3_finalize(statement); [super viewDidLoad]; } sqlite3_close(db); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload