I am using the following function in my application:
+(TeamTournamentLookUp *)getOpponentTeamTournamentLookUp:(int)tournamentId:(int)opponentTeamId
{
TeamTournamentLookUp *objOpponentTTL = nil;
const char *sql = "SELECT TeamTournamentLookUpID, TournamentID, TeamID, NumberOfWins, NumberOfLosses, NumberOfDraws, Points, Rank, IsUserTeam from TeamTournamentLookUp where TournamentID = ? and TeamID = ?";
sqlite3_stmt *selectstmt;
if(sqlite3_prepare_v2(database, sql, -1, &selectstmt, NULL) != SQLITE_OK)
NSAssert1(0, @"Error. '%s'", sqlite3_errmsg(database));
sqlite3_bind_int(selectstmt, 1, tournamentId);
sqlite3_bind_int(selectstmt, 2, opponentTeamId);
if(SQLITE_DONE != sqlite3_step(selectstmt))
{
NSInteger primaryKey = sqlite3_column_int(selectstmt, 0);
objOpponentTTL = [[TeamTournamentLookUp alloc] initWithPrimaryKey:primaryKey];
objOpponentTTL.tournamentId = sqlite3_column_int(selectstmt, 1);
objOpponentTTL.teamId = sqlite3_column_int(selectstmt, 2);
objOpponentTTL.numberOfWins = (sqlite3_column_type(selectstmt, 3) == SQLITE_NULL) ? 0 : sqlite3_column_int(selectstmt, 3);
objOpponentTTL.numberOfLosses = (sqlite3_column_type(selectstmt, 4) == SQLITE_NULL) ? 0 : sqlite3_column_int(selectstmt, 4);
objOpponentTTL.numberOfDraws = (sqlite3_column_type(selectstmt, 5) == SQLITE_NULL) ? 0 : sqlite3_column_int(selectstmt, 5);
objOpponentTTL.points = (sqlite3_column_type(selectstmt, 6) == SQLITE_NULL) ? 0 : sqlite3_column_int(selectstmt, 6);
objOpponentTTL.rank = (sqlite3_column_type(selectstmt, 7) == SQLITE_NULL) ? 0 : sqlite3_column_int(selectstmt, 7);
objOpponentTTL.isUserTeam = (sqlite3_column_type(selectstmt, 9) == SQLITE_NULL) ? 0 : sqlite3_column_int(selectstmt, 9);
}
return objOpponentTTL;
}
Basically I am returning an Object of TeamTournamentLookUp class.
In the code I am allocating the object: objOpponentTTL = [[TeamTournamentLookUp alloc] initWithPrimaryKey:primaryKey];
Now my question is where should I release the object?