Note that there are some explanatory texts on larger screens.

plurals
  1. POUIButton tag fetching last update value
    text
    copied!<p>I need to create multiple buttons in UIWebView. So, i used tag for button. And i save the button tag to database with INTEGER . But it's not saving proper value. Each button tag having text in database. Later i need to retrieve. But after storing last value to database and click anyother button it fetching only last updated value. Why this happen?</p> <p>Table:</p> <pre><code>textnotes text_id button_id hi 1 1 how are you 1 3 im fine 2 7 This is test 2 11 </code></pre> <p>UIButton:</p> <pre><code>int gTag = 1; webviewbutton.tag = gTag; gTag++; [wbCont.scrollView addSubview:webviewbutton]; </code></pre> <p>Insert:</p> <pre><code>const char *sqlInsert = [[NSString stringWithFormat:@"insert into textnote (textnotes,text_id,button_id ) values ('%@','%@','%ld')", txtview.text,artID,(long)webviewbutton.tag] cStringUsingEncoding:NSUTF8StringEncoding]; </code></pre> <p>Retrieve button tag with text from database:</p> <pre><code> textArray=[[NSMutableArray alloc]init]; webbutton_art=[[NSMutableArray alloc]init]; webbutton_button=[[NSMutableArray alloc]init]; if (sqlite3_open([path UTF8String], &amp;database) == SQLITE_OK) { const char *sql = [[NSString stringWithFormat: @"SELECT textnotes,text_id,button_id FROM textnote where button_id = '%ld' AND text_id = '%@' ",(long)webviewbutton.tag,artID]cStringUsingEncoding:NSUTF8StringEncoding]; NSLog(@"sql is %s",sql); sqlite3_stmt *statement; if (sqlite3_prepare_v2(database, sql, -1, &amp;statement, NULL) == SQLITE_OK) { while (sqlite3_step(statement) == SQLITE_ROW) { txtstring = [[NSString alloc] initWithUTF8String: (const char *) sqlite3_column_text(statement, 0)]; webbutton_textartid = sqlite3_column_int(statement, 1); webbutton_buttontag= sqlite3_column_int(statement, 2); [textArray addObject:txtstring]; [webbutton_art addObject:@(webbutton_textartid)]; [webbutton_button addObject:@(webbutton_buttontag)]; if( webbutton_art &amp;&amp; webbutton_button ){ for(int i=0;i&lt;[textArray count];i++){ txtview = [[UITextView alloc]initWithFrame:CGRectMake(0,0,320,568)]; txtview.font = [UIFont fontWithName:@"Helvetica" size:12]; txtview.text=[textArray objectAtIndex:i]; [self.view addSubview:txtview]; } } </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