Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplay array value to view
    primarykey
    data
    text
    <p>Im storing some values in my server. Then i fetched that values using JSON and added to local database table. Then i need to display that values to view. But array values displaying in NSLog. It won't displaying in view. I don't need to display in TableView.</p> <p>code:</p> <pre><code>-(void) addDataToArray{ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; //NSLog(@"docs dir is %@", documentsDirectory); NSString *path = [documentsDirectory stringByAppendingPathComponent:@"db1.sqlite"]; //NSLog(@"filepath %@",path); mArray = [[NSMutableArray alloc]init]; if (sqlite3_open([path UTF8String], &amp;database) == SQLITE_OK) { // const char *sql = "SELECT id,cat_name FROM categories order by order_by"; const char *sql = "SELECT * FROM categories"; NSLog(@"Sql is %s",sql); sqlite3_stmt *statement; int catID = 0; if (sqlite3_prepare_v2(database, sql, -1, &amp;statement, NULL) == SQLITE_OK) { // We "step" through the results - once for each row. while (sqlite3_step(statement) == SQLITE_ROW) { NSString *catName = [[NSString alloc] initWithUTF8String: (const char *) sqlite3_column_text(statement, 1)]; NSLog(@"catName is %@",catName); [mArray addObject:catName]; // [self.view addConstraints:mArray]; NSLog(@"mArray is %@", mArray); [catName release]; catID = sqlite3_column_int(statement, 0); } } sqlite3_finalize(statement); } else { sqlite3_close(database); NSAssert1(0, @"Failed to open database with message '%s'.", sqlite3_errmsg(database)); // Additional error handling, as appropriate... } } - (void)connectionDidFinishLoading:(NSURLConnection *)connection { NSLog(@"connectionDidFinishLoading"); [self addDataToArray]; } </code></pre> <p>NSLog:</p> <pre><code>catName is person1 mArray is ( person1 ) catName is person2 mArray is ( person1 person2 ) </code></pre> <p>TextView:</p> <pre><code> UITextView *txt=[[UITextView alloc]initWithFrame:CGRectMake(50, 50, 200, 200)]; // txt.text=[mArray objectAtIndex:0]; [self.view addSubview:txt]; for (int i = 0; i&lt;[mArray count]; i++ ) { NSLog(@"index %d",i); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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