Bronze solution


#1

Here is my bronze solution (inspired by some solutions here). It’s with a Stepper Control

First init the songNumber = 10, in the init method.

Then, change the fetch method like this:

[code] // Initiate the request…
if (rssType == ListViewControllerRSSTypeBNR){
[[BNRFeedStore sharedStore] fetchRSSFeedWithCompletion:completionBlock];

    [[self navigationController] setToolbarHidden:YES animated:YES];

}
else if (rssType == ListViewControllerRSSTypeApple)
{
    
    
    [[self navigationController] setToolbarHidden:NO animated:YES];
    toolbar = [[self navigationController] toolbar];
            
    // Stepper
    UIStepper *stepper = [[UIStepper alloc] init];
    [stepper setBounds:CGRectMake(0, 0, 50, 50)];
    [stepper setValue:songNumber];
    [stepper addTarget:self action:@selector(stepperChanged:) forControlEvents:UIControlEventValueChanged];
        
    // Label
    label = [[UILabel alloc] init];
    [label setText:[NSString stringWithFormat:@"Songs: %d", songNumber]];
    [label setBounds:CGRectMake(0, 0, 100, 50)];
    [label setBackgroundColor:[UIColor clearColor]];
        
    // Wrap them in a bar button item
    UIBarButtonItem *scItem = [[UIBarButtonItem alloc] initWithCustomView:stepper];
    UIBarButtonItem *text = [[UIBarButtonItem alloc] initWithCustomView:label];
    
    // Add buttons to the toolbar
    [toolbar setItems:[NSArray arrayWithObjects: text, scItem, nil] animated:YES];
    
    [[BNRFeedStore sharedStore] fetchTopSongs:songNumber
                               withCompletion:completionBlock];
    

}

[/code]

This basically works, but I the activity indicator starts to show and does not get removed if
I click on the stepper many times consecutively and in a fast manner (also increasing, decreasing it).
Any idea why this would happen? Thanks.

This is handler code for the stepper, by the way:

[code]

  • (IBAction)stepperChanged:(UIStepper *)sender {
    songNumber = [sender value];
    NSLog(@"# %d", songNumber);
    [label setText:[NSString stringWithFormat:@“Songs: %d”, (int)songNumber]];
    [self fetchEntries];

}[/code]