diff --git a/EGODatabase.h b/EGODatabase.h index 83ccf75..ce5290a 100755 --- a/EGODatabase.h +++ b/EGODatabase.h @@ -39,8 +39,11 @@ @private sqlite3* handle; BOOL opened; + NSStringEncoding stringEncoding; } +@property (nonatomic,assign) NSStringEncoding encoding; + + (id)databaseWithPath:(NSString*)aPath; - (id)initWithPath:(NSString*)aPath; diff --git a/EGODatabase.m b/EGODatabase.m index 8f19c39..0da993d 100755 --- a/EGODatabase.m +++ b/EGODatabase.m @@ -72,6 +72,7 @@ - (void)bindObject:(id)obj toColumn:(int)idx inStatement:(sqlite3_stmt*)pStmt; @implementation EGODatabase @synthesize sqliteHandle=handle; +@synthesize encoding=stringEncoding; + (id)databaseWithPath:(NSString*)aPath { return [[[[self class] alloc] initWithPath:aPath] autorelease]; @@ -81,6 +82,7 @@ - (id)initWithPath:(NSString*)aPath { if((self = [super init])) { databasePath = [aPath retain]; executeLock = [[NSLock alloc] init]; + stringEncoding = NSUTF8StringEncoding; } return self; @@ -278,7 +280,9 @@ - (EGODatabaseResult*)executeQuery:(NSString*)sql parameters:(NSArray*)parameter EGODatabaseRow* row = [[EGODatabaseRow alloc] initWithDatabaseResult:result]; for(x=0;x +- (void)requestDidStartLoad:(EGODatabaseRequest*)request; - (void)requestDidSucceed:(EGODatabaseRequest*)request withResult:(EGODatabaseResult*)result; // result will be nil for EGODatabaseUpdateRequest - (void)requestDidFail:(EGODatabaseRequest*)request withError:(NSError*)error; @end diff --git a/EGODatabaseRequest.m b/EGODatabaseRequest.m index 6ef2d28..49af04c 100644 --- a/EGODatabaseRequest.m +++ b/EGODatabaseRequest.m @@ -28,6 +28,7 @@ #import "EGODatabase.h" @interface EGODatabaseRequest (Private) +- (void)didStartLoad; - (void)didSucceedWithResult:(EGODatabaseResult*)result; - (void)didFailWithError:(NSError*)error; @end @@ -54,6 +55,8 @@ - (void)main { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; [delegate retain]; + [self didStartLoad]; + if(self.requestKind == EGODatabaseUpdateRequest) { BOOL result = [self.database executeUpdate:query parameters:parameters]; @@ -97,6 +100,12 @@ - (void)main { [pool release]; } +-(void)didStartLoad{ + if(delegate && [delegate respondsToSelector:@selector(requestDidStartLoad:)]) { + [delegate requestDidStartLoad:self]; + } +} + - (void)didSucceedWithResult:(EGODatabaseResult*)result { if(delegate && [delegate respondsToSelector:@selector(requestDidSucceed:withResult:)]) { [delegate requestDidSucceed:self withResult:result]; @@ -110,6 +119,7 @@ - (void)didFailWithError:(NSError*)error { } - (void)dealloc { + [query release]; [parameters release]; [database release]; [super dealloc];