CS193p Assignment 4
I started working on Assignment 4 of the CS193 fall 2011 course.
- Flickr API - I got the Flickr API working and am able to access the top locations and photos per locations. I did have a bit of trouble figuring out the data structure that Flickr is giving. I got mixed up in Array’s and Dictionaries. Why does the flickrFetch API give an NSArray and not an NSDictionary?
- Storyboard - I had a lot of trouble getting a good storyboard. However after seeing Lecture 10, I decided to delete everything and restart from scratch. Just as Paul Hegarty did during the Lecture. And then everything went pretty smooth;
- Place Photolist - Getting the Photlist for a specifc place working got me bogged down for a while. Until I realised that I did not check the Segue identifier in the right way. I used ‘==’ and not ‘isEqual:’. After that it worked well;
- Description dictionary - I was not able to get the information on the description through the ‘description._content’-key. So I had to take the long way to retrieve it;
- Title and description length - the lenghts of these two items is much longer than the screen width. What is the best way to present them?
- Photo location list segue - I do not understand how this segue works. You do not have to set something up. Just add the segue to a table view controller seem to be enough to have it respond to a row selection? From where should I setup the segue? The window? the table? the cell? The window as anchor works with a performSegue: in didSelectRow:, but why?)
- Titles - I have been playing with the window titles a bit in order to display city name and or photo title. I would like to limit the number of characters and append a ‘...’ at the end. If I use a minimum size that is to large I get an error message. So I must take into account the maximum allowed length. Still have to work on that;
- Photo display - I got the photo displaying working, but I was not able to set it to fill with UIContentMode. It turns out that I implemented conflicting procedures: in storyboard it was set to AutoFill, but in the methods I un-implemented this fill by setting the image size and/or frame;
- iPad - I had to rewatch the course on the iPad to see how it worked again. Setting up the storyboard was reasonable straightforward. I had to remember to setup the photoViewController as detailedView. And to not use segue to present photo’s. It seems to be working. I have now to address the details;
- Generic TabBarViewController - just like in the course I created a generic TabBarViewController, in which I implemented the DetailedSplitViewController methods. I get the impression from the assignment that there is also another solution;
- Subclassing - I created a subclass for showing a list of photos: one for the most popular and one for a single place;
- Sections - I implement the extra requirement: sections in the Places-list. I had a hard getting my head around it, fighting with arrays and dictionaries. My final approach was to enumerate all the places I had retrieved, extracted the country (careful here). Each country was added to a dictionary and each place an array in that dictionary. As the tableview does not like dictionaries, I had to convert it back to an array by enumerating over the keys. I added the name of the country as the title of a section. The provence is now the detail;
- NSRange - To find the country from a place, I had to extract the last element in the location. Normally a location consists of three elements divided by comma’s. So I use rangeOfString: to find the location of the comma. However when there is no comma, I get a crazy number. So I can not trust it. However the length is then 0, so I can use this to see whether there is a comma in a string (anyway I no longer use this approach, see next item);
- Location parts - As noted a location can consist of three parts. NSString has a method (componentsSeperatedByString:) to extract these parts given a delimiter @”,”. This method provides an array. The first part will be the name of the city and the last part the name of the country. And if there are only two parts, it does not matter. I got these working after listening to lecture 11 (?). I needed to use the method ValueForKeyPath:;
- Reset contentMode - after loading an image one has to reset the contentMode for the imageView and scrollView, otherwise parts of the image can be cut off. I used a contentMode which fits the image to the size of the view. Also the zoomFactor must be reset to 1;
- Image in TabBar - I would like to suppress the tabbar when showing the image, but have not yet found out how;