Gio Bact Gio Bact - 11 months ago 63
iOS Question

iOS error: Thread 1:EXC_BAD_ACCESS(code=1,address=0x726f635f)?

I got this problem in developing my first iOS app that manage a DB.
I have a DB with scores of the game and want to show them in a table, when (at runtime) I enter the scoreView app crash with this error:

Thread 1:EXC_BAD_ACCESS(code=1,address=0x726f635f)

Here is the code that Xcode show me as responsible of this problem:

if (sqlite3_prepare_v2(database, sql , -1, &select_statement, NULL)
while (sqlite3_step(select_statement) == SQLITE_ROW){
// read from DB
NSString *rank = [NSString stringWithUTF8String:(char *)sqlite3_column_text(select_statement, 0)];
NSString *name = [NSString stringWithUTF8String:(char *)sqlite3_column_text(select_statement, 1)];
NSString *score = [NSString stringWithUTF8String:(char *)sqlite3_column_text(select_statement, 2)];
NSString *date = [NSString stringWithUTF8String:(char *)sqlite3_column_text(select_statement, 3)];

// I insert all the string in a dictionary
NSDictionary *dictionary = [[NSMutableDictionary alloc] initWithObjectsAndKeys:rank,@"Rank",name,@"Name",score,"Score",date,@"Date",nil];
[tempList addObject:dictionary];

self.list = tempList;

The error is in the line:

NSDictionary *dictionary = [[NSMutableDictionary alloc] initWithObjectsAndKeys:rank,@"Rank",name,@"Name",score,"Score",date,@"Date",nil];

After reading from DB I'm trying to save all strings in a dictionary and at the end all dictionaries (in tempList) go into "list", an array to show scores in the table.
I read on the internet that this problem may be caused by different threads accessing the same object but I don't know how to solve it.
I was following a tutorial for use DB in iOS app and of course this problem wasn't there.
If someone can help me I'll very appreciate, thank you.

Dan Dan
Answer Source

You have a syntax error:

... score, "Score" ...

should read:

... score, @"Score" ...