BugsBiteBugs / sqlitepersistentobjects

Automatically exported from code.google.com/p/sqlitepersistentobjects
0 stars 0 forks source link

UIImage can not save #82

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi. 
sqlitepersistentobjects is very good. But I meet a question sereval days. I
try to solve it, But I failed. Please help me. I am developing a program
for iphone.

First, I use the createEditableCopyDatabaseIfNeeded function to create a
writable database.

- (void) createEditableCopyDatabaseIfNeeded {

    BOOL success;  
    NSFileManager *fileManager = [NSFileManager defaultManager];  
    NSError *error;  
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);  
    NSString *documentsDirectory = [paths objectAtIndex:0];  
    NSString *writeableDBPath = [documentsDirectory
stringByAppendingPathComponent:@"southtravelguide.sqlite3"];  
    success = [fileManager fileExistsAtPath:writeableDBPath];  
    if (success) {  
        // The writable database does not exist, so copy the default to the
appropriate location.  

        [[SQLiteInstanceManager sharedManager]
setDatabaseFilepath:writeableDBPath];  

        return;  
    }  

    NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath]
stringByAppendingPathComponent:@"southtravelguide.sqlite3"];  
    success = [fileManager copyItemAtPath:defaultDBPath toPath:writeableDBPath
error:&error];
    if (!success) {  
        NSAssert1(0, @"Failed to create writable database file with message
'%@'.", [error localizedDescription]);  
    }  

    [[SQLiteInstanceManager sharedManager] setDatabaseFilepath:writeableDBPath];    

}

And I write a ImageCache class. And I attached the class. And I found that
save can work, and findFirstByWbkey can not work. I don't know why. Thanks.

Original issue reported on code.google.com by omnilanc...@gmail.com on 21 Mar 2010 at 4:03

Attachments: