I have the following code that causes me issues, even if I don't release the Array or the object I still get issues. Is this not the right way of doing this?
The table view loads all the data fine but if I try scrolling or clicking on one of the cells that is where I get the issue. If I just leave it alone the app does not crash.
The crash is on the following line in SCGlobal.m
[valuesArray addObject:value];
And here is my code
db = [FMDatabase databaseWithPath:databasePath];
if (![db open]) {
NSLog(@"Could not open db.");
}
FMResultSet *rs;
if (self.RootID == nil){
rs = [db executeQuery:@"select rowid,* from DB where RootID IS NULL"];;
}else{
rs = [db executeQuery:@"select rowid,* from DB where RootID = ?", [self.RootID stringValue]];
}
NSMutableArray *itemsArray = [[NSMutableArray alloc] init];
while ([rs next]) {
MenuObject *tempObject = [[MenuObject alloc] initWithItemID:[NSNumber numberWithInt:[rs intForColumn:@"RootID"]] title:[rs stringForColumn:@"Name"] content:[rs stringForColumn:@"Content"]];
[itemsArray addObject:tempObject];
[tempObject release];
tempObject = nil;
}
if ([db hadError]) {
NSLog(@"Err %d: %@", [db lastErrorCode], [db lastErrorMessage]);
}
self.clearsSelectionOnViewWillAppear = YES;
tableModel = [[SCTableViewModel alloc] initWithTableView:self.tableView withViewController:self];
SCClassDefinition *taskClassDef = [SCClassDefinition definitionWithClass:[MenuObject class]
withPropertyNames:[NSArray arrayWithObjects:@"title", @"itemID",@"content", nil]];
SCArrayOfObjectsSection *tasksSection = [SCArrayOfObjectsSection sectionWithHeaderTitle:nil withItems:itemsArray withClassDefinition:taskClassDef];
tasksSection.allowEditDetailView = FALSE;
[tableModel addSection:tasksSection];
[itemsArray release];