jump to navigation

More problems solved 24 June 2009

Posted by Oliver Mason in Apple, iphone.
trackback

DAY 10, second part. I was really annoyed by those database errors, and built in assertions to check for the size of the file, and whether the file existed at all. I think sqlite creates a database if the file doesn’t exist, and on subsequent runs the database is then empty and failure happens.

Then I had the nice situation where the program worked in the simulator, but not on the device (I wanted to check the speed on the actual phone). Again, first the file doesn’t exist, and then it’s empty. XCode didn’t seem to copy the file over. Finally it dawned on me, as I was searching for mentions of problems with copying files into the documents folder: my database file was not in the documents folder, it was within the application bundle. I thought about copying it over when the app first starts, but then, why bother? It’s a read-only database, so all I needed to do was to change the path in the db init code, using the application bundle instead of the documents folder, and hey presto, success!

I guess the problem was that I looked at the sample code for db stuff in the iPhone development book. Here a database is created in the documents folder, and I assumed that would be where my db should reside. Confusing, but finally sorted. Now I can go to sleep in peace!

Advertisements

Comments»

1. More problems solved - 24 June 2009

[…] Original post by ojmason […]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: