У меня есть следующий код, который я вызываю с помощью этого оператора: SQLiteDB * db = [[[SQLiteDB alloc] init] autorelease];
Проблема в том, что «sharedSQLiteDB» не вызывается, а скорее«allocWithZone» есть, и поэтому «checkIfDatabaseExists» не вызывается, где база данных создается.
Я не понимаю, почему ... (то есть, что я делаю не так?)
#import "SQLiteDB.h"
static SQLiteDB *sharedSQLiteDB = nil; // makes this a singleton class
@implementation SQLiteDB
@synthesize searchPaths, documentPath, databasePath, cDatabasePath;
#pragma mark Singleton Methods
+ (SQLiteDB *) sharedSQLiteDB {
if(!sharedSQLiteDB) {
sharedSQLiteDB = [[SQLiteDB alloc] init];
[sharedSQLiteDB checkIfDatabaseExists]; // check to see if d/b exists
}
return sharedSQLiteDB;
}
+(id)allocWithZone:(NSZone *)zone { // makes sure another instance is not allocated
if(!sharedSQLiteDB) {
sharedSQLiteDB = [super allocWithZone:zone];
return sharedSQLiteDB;
}
else {
return nil;
}
}
-(id)copyWithZone:(NSZone *)zone {
return self;
}
-(void) release {
// no-op
}