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.


Leave a Reply

Your email address will not be published.