Bug fix for Nerdfeed


#1

addItemsFromChannel: does not work if the cache is empty, because you are sending the addObject: message to nil.

My solution was to test for that condition and set ‘items’

RSSChannel.h

@property (nonatomic, strong) NSMutableArray *items;

RSSChannel.m

- (void)addItemsFromChannel:(RSSChannel *)otherChannel
{       
    for (RSSItem *i in [otherChannel items]) {      
        
        // Cater for cache being empty
        if (![self items]) {            
            NSMutableArray *myItems = [NSMutableArray arrayWithObject:i];
            [self setItems:myItems];
        }
        // If self's items does not contain this item, we add this item   
        if (![[self items] containsObject:i]) {            
            [[self items] addObject:i];
        }
       
        // Sort the array of items by publication date        
        [[self items] sortUsingComparator:^NSComparisonResult(id obj1, id obj2) {
            return [[obj2 publicationDate] compare:[obj1 publicationDate]];
        }];        
    }    
}

#2

thanks for pointing this out!!!