dimanche 29 mars 2015

App Crashes when I get results from second table in sqlite

I have an SQLite database implemented in my xcode project. (I used this tutorial for it.) I have 3 tables in the SQLite file. When I try viewing objects from the first table like so, (I'm using a UITableView):



NSString *query = [NSString stringWithFormat:@"select * from peopleInfo where peopleInfoID=%d", self.recordIDToEdit];

self.results = [[NSArray alloc] initWithArray:[self.dbManager loadDataFromDB:query]];


cellForRow...



self.txtFirstname.text = [[results objectAtIndex:0] objectAtIndex:[self.dbManager.arrColumnNames indexOfObject:@"firstname"]];


Everything works as expected, until I add objects from the second table.



NSString *secondTableQuery = [NSString stringWithFormat:@"select * from secondTable where ID=%d", self.recordIDToEdit];
self.anotherTableResult = [[NSArray alloc] initWithArray:[self.dbManager loadDataFromDB:secondTableQuery]];


When I add that, it crashes saying [__NSArrayI objectAtIndex:]: index 922337206854775807 beyond bounds [0 .. 10].


But, if I take away, either the second table array - self.anotherTableResult, OR I comment out the things I put in cellForRow.. it works fine.


Why does it crash when I retrieve the rows from the second table?


Aucun commentaire:

Enregistrer un commentaire