cs193p – Assignment #6 Part #3

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

Download Photos from Flickr using the background fetching API

Assignment #6 Task #7

Fetch the URLforRecentGeoreferencedPhotos from Flickr periodically (a few times an hour when your application is in the foreground and whenever the system will allow when it is in the background using the background fetching API in iOS). You must load this data into a Core Data database with whatever schema you feel you need to do the rest of this assignment.


Task #7 requires to use the background fetching API instead of using ephemeral sessions like we did in part #2.

Add the background-fetching capability to your target:

cs193p – assignment #6 task #1 - add background fetch capability
add background fetch capability

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

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #6 Part #2

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

… back to the actual task … prevent the “old” top-places table view controller from loading photos we do not need any more:

- (void)viewDidLoad
{
    [super viewDidLoad];
//    [self fetchPlaces];
}

Download Photos from Flickr using URLforRecentGeoreferencedPhotos:

Assignment #6 Task #1

Your application must work identically to last week except that where you are displaying the “top places” (as reported by Flickr), you are going to display the “top regions” in which photos have been taken. You will calculate the most popular regions from the data you gather periodically from the URLforRecentGeoreferencedPhotos.

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

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #6 Part #1

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

You might have noticed that since the last post – finishing with the tasks of assignment #5 – nearly half a year has gone by. Partly, because I had to earn money … if you feel the need to help there, you are welcome to use the flattr or paypal buttons at the end of this post, or just buy one of my apps in the AppStore and write nice reviews. But mostly, I delayed this post because of the structure of this assignment … there is none … where all the other assignments were straight forward, and most of the tasks were separated from each other, the tasks of this assignment are interspersed with each other. I could not find a way to separate them in a sensible way. I tried, I failed …

I have got a couple of emails asking about the sixth assignment. My guilty conscience forces me to continue. WWDC starts any minute, I should try to finish before iOS 8 is available (to late … ).
Continue reading “cs193p – Assignment #6 Part #1”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #6 Extra Task #4

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

Make one or more of your table views searchable. Check out UISearchDisplayController and UISearchBar.

Add a bar button to enable the search functionality in code and initialize it lazily:

@property (nonatomic, strong) IBOutlet UIBarButtonItem *searchButton;
...
- (UIBarButtonItem *)searchButton
{
    if (!_searchButton) {
        _searchButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSearch
                                                                      target:self
                                                                      action:@selector(searchButtonPressed:)];
                         
    }
    return _searchButton;
}

- (void)viewDidLoad
{
    ...
    self.navigationItem.rightBarButtonItem = self.searchButton;
}

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

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #6 Extra Task #3

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

Have a row in your main table view called “All” which shows all the photos (not just the photos with a certain tag). Then have the table that appears when you click on “All” be divided into sections by tag (i.e., each section is one of the tags). The simplest way to add the “All” row is to update the information in your database a little bit rather than trying to special-case your table view code (though you will need a special case to turn on sections for that particular table of all photos since you don’t want other tables of photos to have sections). Luckily “All” is alphabetically at the top of the list of types of places, but can you think of a way to modify your schema/fetch criteria to ensure that it is always the top item in the list even if it’s not called “All” or if there were an “Abattoir” tag in the list?

Just add an additional tag for “All” to all photos. To circumvent to “Abattoir” sorting problem, name it so that it will be always be first, e.g.:

#define ALL_TAGS_STRING @"00000"
...
+ (NSSet *)tagsFromFlickrInfo:(NSDictionary *)photoDictionary
       inManagedObjectContext:(NSManagedObjectContext *)context
{
    ...
    tagStrings = [tagStrings arrayByAddingObject:ALL_TAGS_STRING];
    ...
}

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

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #6 Extra Task #2

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

Allow users to delete photos (i.e. they no longer appear in tables). You should do it in a way that makes it so that the UIRefreshControl does not bring them back!

Deleting of cells is enabled by providing the appropriate delegate method. There delete the current photo and save the core-data document:

-  (void)tableView:(UITableView *)tableView
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
 forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        Photo *photo = [self.fetchedResultsController objectAtIndexPath:indexPath];
        [photo.managedObjectContext performBlock:^{
            [photo delete];
            [[SharedDocumentHandler sharedDocumentHandler] saveDocument];
        }];
    }
}

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

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

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”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail