Skip to content

Instantly share code, notes, and snippets.

@jessicamoore112
Last active December 16, 2015 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jessicamoore112/5433625 to your computer and use it in GitHub Desktop.
Save jessicamoore112/5433625 to your computer and use it in GitHub Desktop.
- (void) fetchEntriesNew:(NSInteger )pageNumber
{
UIView *currentTitleView = [[self navigationItem] titleView];
UIActivityIndicatorView *aiView = [[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
[[self navigationItem] setTitleView:aiView];
[aiView startAnimating];
channel = [[TheFeedStore sharedStore] fetchWebService:pageNumber withCompletion:^(RSSChannel *obj, NSError *err){
[[self navigationItem] setTitleView:currentTitleView];
if (!err) {
int currentItemCount = [[channel items] count];
channel = obj;
int newItemCount = [[channel items] count];
NSLog(@"Total Number Of Entries Are: %d", newItemCount);
counter = (newItemCount / 10) + 1;
NSLog(@"New Counter Should Be %d", counter);
int itemDelta = newItemCount - currentItemCount;
if (itemDelta > 0) {
NSMutableArray *rows = [NSMutableArray array];
for (int i = 0; i < itemDelta; i++) {
NSIndexPath *ip = [NSIndexPath indexPathForRow:i inSection:0];
[rows addObject:ip];
}
[[self tableView] insertRowsAtIndexPaths:rows withRowAnimation:UITableViewRowAnimationBottom];
[aiView stopAnimating];
isDownloading = NO; //////////////// Tried HERE
}
}
else {
isDownloading = NO;
// If things went bad, show an alert view
NSString *errorString = [NSString stringWithFormat:@"Fetch failed: %@",
[err localizedDescription]];
// Create and show an alert view with this error displayed
UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"Error"
message:errorString
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[av show];
}
}];
[[self tableView] reloadData];
///////////////////////// TRIED HERE
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
float endScrolling = scrollView.contentOffset.y + scrollView.frame.size.height;
if (endScrolling >= scrollView.contentSize.height)
{
if(!isDowloading)
{
isDownloading = YES;
NSLog(@"Scroll End Called");
NSLog(@"New Counter NOW is %d", counter);
[self fetchEntriesNew:counter];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment