Note that there are some explanatory texts on larger screens.

plurals
  1. POProblem while scrolling Table View
    text
    copied!<p>I have the following problem while i scroll the table view: </p> <pre><code>NSCFString objectAtIndex:]: unrecognized selector sent to instance </code></pre> <p>I create NSDictionary tableContents and when i scroll it becomes deallocated. This is my code: </p> <pre><code>- (void)viewDidLoad { lessonsInGroup1 = [NSMutableArray array]; lessonsInGroup2 = [NSMutableArray array]; lessonsInGroup1 = [self grabRowsInGroup:@"1"]; lessonsInGroup2 = [self grabRowsInGroup:@"2"]; NSDictionary *temp =[[NSDictionary alloc]initWithObjectsAndKeys:lessonsInGroup1,@"General Information",lessonsInGroup2,@"LaTeX Examples", nil]; //[[tableContents alloc] init]; self.tableContents =temp; [temp release]; NSLog(@"table %@",self.tableContents); NSLog(@"table with Keys %@",[self.tableContents allKeys]); self.sortedKeys =[[self.tableContents allKeys] sortedArrayUsingSelector:@selector(compare:)]; NSLog(@"sorted %@",self.sortedKeys); [lessonsInGroup1 release]; [lessonsInGroup2 release]; //[table reloadData]; // Uncomment the following line to display an Edit button in the navigation bar for this view controller. // self.navigationItem.rightBarButtonItem = self.editButtonItem; [super viewDidLoad]; </code></pre> <p>}</p> <pre><code>- (NSMutableArray *) grabRowsInGroup:(NSString*)GroupID{ NSMutableArray *groupOfLessons; groupOfLessons = [[NSMutableArray alloc] init]; char *sqlStatement; int returnCode; sqlite3_stmt *statement; NSString *databaseName; NSString *databasePath; // Setup some globals databaseName = @"TexDatabase.sql"; // Get the path to the documents directory and append the databaseName NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDir = [documentPaths objectAtIndex:0]; databasePath = [documentsDir stringByAppendingPathComponent:databaseName]; // Setup the database object sqlite3 *database; // Open the database from the users filessytem if(sqlite3_open([databasePath UTF8String], &amp;database) != SQLITE_OK) { fprintf(stderr, "Error in opening the database. Error: %s", sqlite3_errmsg(database)); sqlite3_close(database); return; } sqlStatement = sqlite3_mprintf( "SELECT * FROM Lessons WHERE LessonGroup = '%s';", [GroupID UTF8String]); returnCode = sqlite3_prepare_v2(database, sqlStatement, strlen(sqlStatement), &amp;statement, NULL); if(returnCode != SQLITE_OK) { fprintf(stderr, "Error in preparation of query. Error: %s", sqlite3_errmsg(database)); sqlite3_close(database); return; } returnCode = sqlite3_step(statement); while(returnCode == SQLITE_ROW) { NSString *aLessonID = [NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 0)]; NSString *aLessonGroup = [NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 1)]; NSString *aLessonTopic = [NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 2)]; NSString *aLessonText = [NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 3)]; NSString *aLessonCode = [NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 4)]; NSString *aLessonPicture = [NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 5)]; /*NSLog(aLessonID); NSLog(aLessonGroup); NSLog(aLessonTopic); NSLog(aLessonText); NSLog(aLessonCode); NSLog(aLessonPicture);*/ // Create a new busCit object with the data from the database Lesson *lesson = [[Lesson alloc] initWithLessonID:aLessonID LessonGroup:aLessonGroup LessonTopic:aLessonTopic LessonText:aLessonText LessonCode:aLessonCode LessonPicture:aLessonPicture]; [groupOfLessons addObject:lesson]; returnCode = sqlite3_step(statement); } sqlite3_finalize(statement); sqlite3_free(sqlStatement); return [groupOfLessons autorelease]; </code></pre> <p>}</p>
 

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