views:

23

answers:

0

I've got code that uses a shared instance object (Database) as a placeholder for a few application variables that need to be checked at different parts of the app. Inside of that shared instance, I have an object called Session that has 4 variables in it (ID, Name, StartTime, EndTime). I init the session and pass it into the shared instance of Database. So far, everything works.

Then, I have code that changes the variables inside of session. It takes a session ID and changes the session by querying a sqlite3 database for the new session parameters. Again, everything is working.

Finally, I have a table of all the sessions and a place that lists the current session name. I go to the table, select a session, and it comes back to the main window. The window then tries to set the label of CurrentSession to the Name variable inside of the Session object inside the shared instance of Database.

This only works 50% of the time. Sometimes when I do this, the name changes fine. Other times, it gives me an EXC_BAD_ACCESS error and kills the app. I understand that this might be a memory management problem...but I have no clue how to track it down.

Here is the code that I use to set my Session object:

_sessionID = sessionID;
_sessionName = [NSString stringWithUTF8String:(const char*)sqlite3_column_text(db.stmt,0)];
_sessionState = sqlite3_column_int(db.stmt, 1);