Also, I think the reason you are getting this huge stack trace is because you are using NSAssert. The bottom line is that you KNOW that it failed at that point (you are effectively duplicating some logic at that point using the assert). You need to know WHY it failed to open the database.

To be fair, I don't know if NSAssert forces it to print a whole stack trace by throwing an exception, so this is just conjecture, but it looks likely considering the error in the stack trace is the same as the error you "typed". For this usage, you are NOT getting any additional usable information by using NSAssert, and it may be confusing the problem more, considering the assert will "hit" every time because the 0 evaluates to false. With traditional C assert, I know this will terminate the program. Throwing an exception would effectively do the same thing to your program/

Chances are, the path to the sqlite file isn't right, or the file itself isn't actually being deployed to the target. Finally, another option is that you didn't include the right SQLite framework. IIRC, there is SQLITE and SQLITE3 that you can include.

To resolve the problem reported above, I tried to log the result returned from sqlite3_open. I got 14 ie. SQLITE_CANTOPEN. I checked permission for Documents and found that some permissions were not read & write. When I changed all to read & write, it started working properly

Now there are some doubts :

1. Is there any-other folder in which I should store SQLite3 db... other than documents.. should I store it in ~/Library/Application Support/ or any other folder?

2. Can we check it via our code that- folder in which we are storing the db file has appropriate permissions or not?

3. If folder does not have appropriate permission then can we change it via code?

Can anyone clear these doubts or tell me the standard way to implement my requirements?

MacRumors attracts a broad audience
of both consumers and professionals interested in
the latest technologies and products. We also boast an active community focused on
purchasing decisions and technical aspects of the iPhone, iPod, iPad, and Mac platforms.