CS193p Assignment 5
After watching lecture 11 and 12, I started working on this assignment. The lecture on version control is also useful, although I had already found out most things.
- Threading - I created 4 four threads for each time I access Flickr. Not sure if it is working though. I see that the threads are created. I can use the interface while the data is loading. So all looks good;
- Concurrent loads - I noticed that I could select another image during a load, which will turn into another image loading. Does not look very good, so I limit myself to onen load at the time. To detect a load I check whether the spinner exists. Probably not a good way to do this;
- Spinner - I copied the Spinner idea from the Lecture, but nothing happens. Do not know why. I changed the TabBarItemes.title to a recognizable text and NSLogged these titles. The titles do change as they should, but it is just the interface that does not update. I figured out the problem. I did put back the original spinner at the wrong place. Now I do it inside the main thread, within the data fetch thread. All seems OK;
- Caching - I figured out how to do the caching. I created a separate class to do all the lifting. I created methods to check the existence of an image, to put it in the cache and to retrieve it. Still need to see how I can do pruning based on size of the cache and oldness of images. The caching also introduced a problem (crash) with changing the titles of the photo view. An assumption seems to go wrong. Also need to see if I can streamline my fetch photo code and how the threading is now working. Should I put the threading inside the method or not?;
- Pruning - the pruning part of caching is working. Had to discover a lot about paths, file attributes and sorting. I put all the writing and pruning in a separate thread.
- Caching crash - the caching crash has been solved. It had nothing to do with caching. It turns out I deleted to often elements from the bar at the top, beyond what was there.
- View switch - I must switch between a list view and a map view of photo’s. I can implement that in various ways, but I do not know the best way yet. It is easy to go one way, but how to switch back? How to create something really symmetric? For the moment I just added a view above the table view and put a button in it. This button provokes a segue to a mapViewController;
- Segue’s - I had a fight with the segue, which should show the mapViewController scene. I think the problem was that I loaded this segue twice. You either define it from the button to the scene and do nothing in the mapViewController. Or you make the segue from the calling ViewController to the Scene and define in a button action that it should be called. But not both!!!
- Map - the MapView controller was easily implemented if you follow the corresponding course. This included the small (not really useful) thumbnails on the callout;
- MapRegion - I calculated the size and location of the Map by traversing all locations, calculating the minimum and maximum latitude and longitude. The average of these gives the center. The minimum and maximum can be used to define the span. This span includes a factor to have a nice area around the pins;
- Inheritance - this application can use a lot of inheritance, but I have not yet figured out how I should use it. But if I want to make maps coming from the places table and the favorite photo table, then I must solve this. I think I will create a sub-class for the MapVC, so that I can disallow asking for images, although this might be solvable through returning a nil as image. And I will create a single class for all tableViewControllers. I then only need to implement a different Flickr retrieve algorithm for each specific tableView. Well at least that is my theory for now;
- Error - I encountered a very strange error: “Couldn’t register com.topPlaces.debug with the bootstrap server. Error: unknown error code. This generally means that another instance of this process was already running or is hung in the debugger.Program received signal: “SIGABRT”.” After searching on Internet I discovered that some zombie processes are running, which can only be killed by restarting the machine. That helped;
- Inheritance scheme - I implemented my inheritance scheme for the tableViewControllers. Also the placeTableViewController is part of this scheme. Thus I have now one MapViewDelegate;
- Place annotations - I create a separate class in order to calculate the annotations for places. I implemented this just like the photo annotations. However a place consists of three parts (city, region and country). I still need to add the third part. Advantage is that the TableViewController does not know anything anymore of the Flickr data keys;
- Flickr retrieval - One of the main difference between the three tableViewController classes is the call to retrieve the data. I do not know how can reduce the code any further with inheritance;
- Accesory action - if I press the accessory button on a pin, I need to call different methods depending on the data. Or have the delegate do different things. It seems I can not redefine the delegate method in a chiled. So I am a bit lost here. Update: I forgot to set the delegate and now all is well;
- Place annotations 2 - I solved this issue by subclassing the PhotoAnnotations class and redefining the methods. The third part was added to the parent class. This part took a long time, as I did not quite understand the MKAnnotation-thing;
- MapViewType - changing the mapViewTypes was super simple;
- Title issue I solved the title issues. Each screen now has a nice title, which is based on the current an previous viewController;
- iPad/iPod - things are still working on the iPad and iPod;
- Resiliency I am not sure whether the app is resilient enough. I encountered several problems with the Flickr API, which I guard against. However there might be more to do;
- Caching problem - I suspected a caching problem. The system retrieved the same photo each time after switching to another one. I thought that the caching did not work. However it turned out that the cache was to small (or image to big) to keep it in the cache all the time. So a 10 MB cache is on the small side. I could also restart the app to remove all kinds of other stuff;
Seems that I am ready to move onto the next assignment.
Page 1 of 1 pages