CS193p Assignment 6
Again I record my progress on this assignment in this post. For this assignment one has to watch several courses. These are basically courses after lecture 11 (Core Location / MapKit):
- Lecture 12 - a lecture on persistence. Not sure if we’ll really need this, as we will work with Core Data. Furthermore several file system stuff taken from this lecture has already been used in Assignment 5;
- Lecture 13 - a lecture on Core Data. Looks complicated, but if you know SQL it is OK. This lecture also discusses notification and categories;
- Lecture 14 - a demo of Core Data. Was nice, have to use a lot;
- Lecture 15 - Watched this lecture. There might some lesson in it for the extra’s of this assignment (textField);
- Lecture 16 - Did not see anything that I might need.
The assignment 6 application is taking shape. I created a new branch to do this work in.
- Storyboard - all the necessary scenes and segues have been created. I added scenes for:the list of vacations, a vacation (static one), the itinerary, the tags and photos for the itinerary and photos for the tags;
- Segue start point - I am still confused where I should start the segue: from the prototype cell or the tableview object? Either one does work. However when I use the cell as start point, the prepareForSegue: method is not called at the right moment;
- VacationTVC - this one is really simple. It only shows the two possible sorting possibilities for vacations. Nearly everything can be setup in the storyboard. The only code I created was to set the title of the navigationItem dynamically. And I pass the vacation on to the next TVC. I had hoped to do this TVC with segue’s from each cell. But that did not seem to work right. So again I started from the TVC object and added a switch to didSelectRowAtIndexPath:;
- PhotoURL - the information stored on each photo in a vacation is insufficient to recover the real Flickr Photo dictionary. One could add all the other retrieved info, but is that worthwhile? So I added a new interface to the PhotoVC setPhotoUrl. This can now be used to retrieve the photo there. But I also had to make an inverse photo-dictionary method. This allowed me to pass the title of the photo to the PhotoVC with the existing interface. I am not happy with this approach. I might redefine the PhotoVC interface to just the photo_title and the photo_url. I think I do not use any other info on the photo. Or I should look into other approaches (delegates?);
- Tags - I created a new entity Tag, which stores all found tags. The Tag has a n:m relationship with Photo. So a tag can point to multiple photo’s and a photo can point to multiple tags. I set both in their category methods. The tag-string taken from a photo is split in multiple tags using a space as delimiter. Still tags seem very messy, so I might clean up a bit more;
- Database creation error - I made an error in creating the database, which consequently resulted in all kind of errors in the predicate. It took me a while to find. I must be more careful;
- n:m relationship - I created an n:m relationship and wanted to use the inverse relationship in the predicate. when fetching the entity Photos, I used the Tag:hasPhotos attribute like “SELF IN %@”, tag.hasphotos. This will retrieve the given set (tag.hasPhotos) of photos;
- Vacation class - I wonder whether I need to introduce a vacation (data) class. In this class all initial file handling can be done. Now I have copies of this in four TVC’s. The same goes for a Vacations Data Class, but here there is no doubling of code. I did create a Vacation-class, which is passed on between controllers;
- Model classes - I do not know which model classes I need for photo’s. In assignment 5 I used just the dictionary provided by the FlickrFetcher. In this assignment I created another class Photo for the same thing. The problem is that these two model classes meet each other and need to exchange data. What I really need is a single class that holds all the data and either gets it from core data or from Flickr. I do not yet know how to solve this;
- Threading - I have some trouble with threads. I need the application to wait on a finished process, which seems to take place in a separate thread. Not sure how to solve that yet. It seems I do not quite understand how things work. When I call performSegue: it seems to continue with the method in which it was called. I thought that it would do first the performSegue: and than come back to the calling method. I expected something totally synchronous. That does not seem to be the case. So at some stage it does do this modal segue and when I select something, it calls the delegate and I might have to do my stuff there. In case of a cancel, probably viewDidLoad is called again? Need to check. Solved by putting things at the right place;
- NSPersistentDataStore - I get an error that there is not such a store. Not sure what is happening and what it is in the first place. Turns out that the document was closed in the mean time. After opening it again I was able to write to it. The closing happened somewhere along the lines. I do not know when this happens. In any case I must now check always the closedStatus before explicitly writing. And I should explicitly write after each change to the database, as it might get into an unable state otherwise. Seems a bit cumbersome, as I would like to minimise disk-access;
- Incomplete photo description - it seems I have an incomplete photo description somewhere, as the wrong thing is written to disk. Still need to figure this out with a lot of NSLog’s (solved);
- Singleton - I solved my earlier problem with the DataStore through a singleton. In fact later I found out that in the hints something similar is suggested. The code is now a lot cleaner. I could throw a lot away. I will experiment with throwing even more away;
- New Vacation - This is the first of the extra tasks. I implemented the first steps in creating a new vacation. It is created, but I still have a flow problem. I am not able to select it, after creation. I am not sure where I should update the tableView;
- Empty entities - The Tag and the Place entity should allows refer to at least one photo. Empty tags and places should not be allowed. Normally when I create a photo, the corresponding Place and Tags entities are created or extended. However what happens when I delete a photo? I am left with empty Tags and Places. How can I prevent that? I added code to check this happening, but I have a feeling that I can solve it in another manner, which is much more lean (do I delete the object in the right way? have I set the entity attributes right?);
- Closed documents - I am not sure how often I should check whether a document is open or not. Now I do it before each fetch. Seems a bit to much. Doing it less would make the code much more lean;
- Top photo places - when I retrieve the top photo’s, I do not get the place name. How can I retrieve the corresponding place names? I guess I need to add something to FlickrFetcher;
- Storing top photos - in assignment 5 it was demanded to store the top photos in a defaults database. I did not bother to do that. However it might add an added complexity, so I would implement this after all. Turned out to be not so difficult (and interesting). However I had an extra complexity due to an inheritance issue;
- Itinerary by date - I should order the itinerary places by date added. Need to extend the data model for this. Will implement this as it gives me a little bit of experience with date and time (not so much);
- Re-ordering - the last thing that I need to do is supporting reordering places in an Itinerary. For that I created an entity Itinerary. This entity has a many link with Place, which is ordered. And each Place is part of an Itinerary. I each Vacation there is only one Itinerary. This Itinerary has the same name as the Vacation. In the corresponding tableView I retrieve all the itineraries (just 1) and use the relation to find all the. corresponding ordered Places. Moving a row in the table should redefine ordering of these places. I got it working thanks to code I found on the Internet;
- Wrapping up - there are still some bugs in the application and it does need some clean-up to remove old code. I could still experiment a bit. However I prefer to start with my own application and dive a bit deeper into that one;
Page 1 of 1 pages