У меня есть следующая функция, но я не знаю, как освободить память определенного временного объекта:
#import <UIKit/UIKit.h>
@interface PatientsSet : NSObject {
NSString *tableid;
NSString *patient_name;
NSString *patient_surname;
NSString *city;
NSString *State;
NSString *phone;
}
@property (nonatomic, retain) NSString *tableid;
@property (nonatomic, retain) NSString *patient_name;
@property (nonatomic, retain) NSString *patient_surname;
@property (nonatomic, retain) NSString *city;
@property (nonatomic, retain) NSString *State;
@property (nonatomic, retain) NSString *phone;
-(id)initWithSet:(NSString *)dd patient_name:(NSString *)dn patient_surname:(NSString *)dsn city:(NSString *)ct state:(NSString *)st phone:(NSString *)ph ;
@end
(я получаю из базы данных SQLITE данные в производный класс NSobject)
Разве я не должен использовать [готовый релиз]; где ??
-(PatientsSet *)getPatientById:(NSString *)ID {
PatientsSet *set;
// Setup the database object
sqlite3 *database;
// Init the doctors_set Array
doctors_set = [[NSMutableArray alloc] init];
//NSString * databasePath1=[ [self getDocumentsDirectory] stringByAppendingPathComponent:databaseName ];
// Open the database from the users filessytem
if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
// Setup the SQL Statement and compile it for faster access
NSString* myString = [NSString stringWithFormat:@"SELECT patients.id,patients.patient_name,patients.patient_surname,patients.phone FROM patients where patients.id = '%@'",ID];
const char *sqlStatement = [myString cString];
sqlite3_stmt *compiledStatement;
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
// Loop through the results and add them to the feeds array
while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
// Read the data from the result row
NSString *aId = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 0)];
NSString *aName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)];
NSString *aDurname = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 2)];
NSString *aPhone = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 3)];
// Create a new set object with the data from the database
set=[[PatientsSet alloc] initWithSet:aId patient_name:aName patient_surname:aDurname city:@"" state:@"" phone:aPhone];
}
}
// Release the compiled statement from memory
sqlite3_finalize(compiledStatement);
}
sqlite3_close(database);
return set;
}