Don't give me any of that 'Star Trek' crap. It's too early in the morning.
Haanjee world!
It's been a little while since I gave an update. Sorry about that. It's currently the second of two exam weeks (in which I have no exams), so I've been spending my time either working (at work), working on university stuff, working on a website I've neglected in some time and (God forbid) socialising with the outside world.
Project-wise, stuff is comming along steadily. I had quite a bit of trouble over the last few days getting core data to play nicely with the information I was downloading from the webservice. The app would recieve the data, store it all nicely in the managed object context (the object you use to interact with the data in the db as objects, which is commited back to the database when the app is suspended or killed) and even display the information it stored to screen, but as soon as the app was closed and reopen, it had forgot the data and had to redownload it.
These two lines of code (not permited in a submitted app as they use a private class, but very usefull for debugging) were useful in showing me the route of the problem.
Class privateClass = NSClassFromString(@"NSSQLCore");
[privateClass setDebugDefault:YES];
These two lines make all the raw SQL statements core data runs in the background display in the console, and after adding them it was quite clear that my app wasn't running the 2000+ comit lines for the products it had downloaded. I feared briefly that it wasn't going to allow me to commit such a large number of items. I ended up solving the problem by creating a new project and implementing a very basic version of the app with harded projects added when it launched. This worked perfectly, which lead me to realise I wasn't adding products to the context in the right way when I downloaded them. A bit of refactoring and my problem was solved.
At the same time I extracted all the work involved with downloading products from the webservice into a dedicated class called ProductFeed. I then used iOS's notification center to register my view controller as a observer of this class so that it would be informed when ProductFeed had finished downloading and parsing the XML. This allows the download to happen asynchronously in the background. I also made a very simple "Drink" class so that I could move product data around as a single object.
This image shows the current state of the app. You get the main category menu (currently hard coded) when the app launches (which triggers a product download if the database is empty) and when you select a category, you are taken to a second view where all the products are listed. Currently all the options lead to the same product list, so my next job will be to introduce a sub category view when all but "all products" is selected so that you can, for example, select a particular region you wish to see whisky from.

This second image shows the output from the console. You can see the first time I launched the app the database was empty (as it will be the first time it is used), so a connection is made to the webservice and the products are downloaded. The second time the app is launched is has products in the database, so it simply uses those, allowing the app to work offline after its first use.

Finaly this image gives you an idea of what my database looks like. It has a drink table for storeing product data, a customer table for customer information, a list table to contain the different lists a user will be able to make (wish list, collection, basket) and a link table that records a product in a list for a customer.
That's about it for project progress. I think things are progressing well right now, however I do need to dedicate more of my time to coding if I'm going to finish in time.
final year project,
iphone development 

Reader Comments