Note that there are some explanatory texts on larger screens.

plurals
  1. POIOS 6- value is not called in cellForRowAtIndexPath though it is defined globally
    primarykey
    data
    text
    <p>I am posting the code which I tried.I am getting string value and then I am adding it to an array and getting the array value too.But problem comes when I try to use the array value in other method ,it's value is blank.</p> <pre><code>//ViewController.h @interface ViewController : UIViewController{ NSArray *totalData; NSString *stringValueVideoiD; NSMutableArray *TableVideoIDArray; NSMutableArray *TableVideoNameArray; } @property (nonatomic,strong) IBOutlet UITableView *tableView; @end //ViewController.m @implementation ViewController @synthesize tableView; - (void)viewDidLoad { TableVideoIDArray=[[NSMutableArray alloc]init]; TableVideoNameArray=[[NSMutableArray alloc]init]; [self getAllRows]; [tableView reloadData]; } -(void) getAllRows{ if(sqlite3_open([databasePath UTF8String], &amp;db) == SQLITE_OK) { NSString *sqlStatement = [NSString stringWithFormat:@"SELECT * FROM table"]; sqlite3_stmt *compiledStatement; if(sqlite3_prepare_v2(db,[sqlStatement UTF8String] , -1, &amp;compiledStatement, NULL)== SQLITE_OK) { while(sqlite3_step(compiledStatement)==SQLITE_ROW) { char *videoId = (char *) sqlite3_column_text(compiledStatement, 1); stringValueVideoiD = [[NSString alloc] initWithUTF8String:videoId]; [TableVideoIDArray addObject:stringValueVideoiD]; NSLog(@"vids array:%@",TableVideoIDArray); //vids array:value is printed char *videoName = (char *) sqlite3_column_text(compiledStatement, 2); NSString *stringValueVideoName = [[NSString alloc] initWithUTF8String:videoName]; [TableVideoNameArray addObject:stringValueVideoName]; totalData=[[NSArray alloc]initWithObjects:stringValueVideoiD,stringValueVideoName,nil]; } } sqlite3_finalize(compiledStatement); sqlite3_close(db); } } -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [totalData count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *simpleTableIdentifier = @"CustomCell"; CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier]; if (cell==nil) { cell=[[CustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier]; } NSLog(@"here:%@",TableVideoIDArray); cell.channelTitle.text=[TableVideoIDArray objectAtIndex:indexPath.row]; //here comes the problem.My console result is 2013-09-18 11:18:24.431 AppName[468:11303] here:( ) 2013-09-18 19:43:35.562 AppName[3991:11303] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'//so guys I need your help why this is happenning or I am making mistakes in my code. </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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