cs193p – Assignment #6 Extra Task #1

Please note, this blog entry is from a previous course. You might want to check out the current one.

Divide all tables of photos (except maybe the “All” table below) into alphabetical sections. This turns out to be easy in table views driven by Core Data, but only if you have an attribute in the database which is “that photo’s section heading” and which sorts in exactly the same order as the photos themselves sort.

Add another attribute to the Photo entity to hold the first letter of each photo title. Recreate its sub class and adjust its category:

+ (Photo *)photoWithFlickrInfo:(NSDictionary *)photoDictionary
        inManagedObjectContext:(NSManagedObjectContext *)context
{
        ...
        photo.firstLetter = [photo.title substringToIndex:1];
        ...
}

Continue reading “cs193p – Assignment #6 Extra Task #1”

Facebooktwittergoogle_plusredditpinterestlinkedintumblrmailFacebooktwittergoogle_plusredditpinterestlinkedintumblrmail

cs193p – Assignment #6 Task #7

Please note, this blog entry is from a previous course. You might want to check out the current one.

Your application must continue to work properly in portrait and landscape and on iPhone 4, iPhone 5 and iPad. It must also verify that it continues to work properly on a physical device (of your choice).

… already done …

Facebooktwittergoogle_plusredditpinterestlinkedintumblrmailFacebooktwittergoogle_plusredditpinterestlinkedintumblrmail

cs193p – Assignment #6 Task #6

Please note, this blog entry is from a previous course. You might want to check out the current one.

When the user refreshes the table view (with the UIRefreshControl), you should refetch the data from Flickr in a thread and update your Core Data database and then update the UI to show any new data. This refresh should automatically invoke upon launch of your application if the Core Data database is empty.

Currently a download starts every time the app launches. Remove the access to Flickr from viewDidLoad and adjust viewWillAppear: to start the download only, when core data is empty:

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    if (!self.sh.managedObjectContext)
        [self.sh useDocumentWithOperation:^(BOOL success) {
        [self setupFetchedResultsController];
        if (![self.fetchedResultsController.fetchedObjects count])
            [self loadPhotosFromFlickr];
    }];
}

The complete code is available on github.

Facebooktwittergoogle_plusredditpinterestlinkedintumblrmailFacebooktwittergoogle_plusredditpinterestlinkedintumblrmail

cs193p – Assignment #6 Task #5

Please note, this blog entry is from a previous course. You might want to check out the current one.

This week’s version should still never block the main thread with any Flickr fetches and should continue to cache photo (non-thumbnail) image data in the file system in the same way as last week’s assignment.

… already done …

Facebooktwittergoogle_plusredditpinterestlinkedintumblrmailFacebooktwittergoogle_plusredditpinterestlinkedintumblrmail

cs193p – Assignment #6 Task #4

Please note, this blog entry is from a previous course. You might want to check out the current one.

The Recents tab should continue to meet all the requirements of the previous assignment. All Recents information should be stored in Core Data (i.e. do not use NSUserDefaults for Recents anymore).

… already done …

Facebooktwittergoogle_plusredditpinterestlinkedintumblrmailFacebooktwittergoogle_plusredditpinterestlinkedintumblrmail

cs193p – Assignment #6 Task #3

Please note, this blog entry is from a previous course. You might want to check out the current one.

Add a thumbnail image (FlickrFetcherPhotoFormatSquare) of each spot to every row in any table view that shows a list of spots. In addition …
a. Don’t ask Flickr for the image data of thumbnails that never appear on screen (i.e. fetch thumbnail image data only on demand).
b. Don’t block your main thread waiting for Flickr to give you a thumbnail’s data.
c. Never ask Flickr for the same thumbnail twice (cache the thumbnails’ data in your Core Data database).

To be able to display the thumbnail, we need its URL, which is currently missing in the core data 🙁 … add a new string attribute to the Photo entity, recreate its NSManagedObject subclass and set it in its category:

+ (Photo *)photoWithFlickrInfo:(NSDictionary *)photoDictionary
        inManagedObjectContext:(NSManagedObjectContext *)context
{
        ...
        photo.thumbnailURL = [[FlickrFetcher urlForPhoto:photoDictionary
                                                  format:FlickrPhotoFormatSquare] absoluteString];
        ...
}

Continue reading “cs193p – Assignment #6 Task #3”

Facebooktwittergoogle_plusredditpinterestlinkedintumblrmailFacebooktwittergoogle_plusredditpinterestlinkedintumblrmail

cs193p – Assignment #6 Task #2 Part #3

Please note, this blog entry is from a previous course. You might want to check out the current one.

Recreate the user-interface from last week’s assignment but rely entirely on the above-mentioned Core Data database to present it.

Copy the files for the last table view controller into the current project. Adjust it to setup the fetched results controller every time the view appears:

- (void)viewWillAppear:(BOOL)animated
{
    ...
    [self.sh useDocumentWithOperation:^(BOOL success) {
        [self setupFetchedResultsController];
    }];
}

Continue reading “cs193p – Assignment #6 Task #2 Part #3”

Facebooktwittergoogle_plusredditpinterestlinkedintumblrmailFacebooktwittergoogle_plusredditpinterestlinkedintumblrmail