I created the db with firefox addon sqlite manager. db can be opened. and the query is working in sqlite manager. but i just can't get the results from FMResultSet.
Code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
// Add the navigation controller's view to the window and display.
NSArray *array = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *path = [array objectAtIndex:0];
NSString *pathString = [path stringByAppendingPathComponent:@"todo.sqlite"];
FMDatabase *db = [FMDatabase databaseWithPath:pathString];
if (![db open]) {
NSLog(@"cannot connect to database");
} else
{
NSLog(@"successfully!");
}
[db open];
FMResultSet *s = [db executeQuery:@"SELECT * FROM todo"];
if (!s) {
NSLog(@"no result set fechted");
}
while ([s next]) {
NSLog(@"%@", [s stringForColumn:@"title"]);
}
[db close];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}