没有调用简单委托方法



我已经搜索了类似的问题,但我只是无法理解为什么这不起作用。我做的一切都是按照教程和教程项目工作,但我做的一切都差不多,没有结果。

我有我的InboxViewController与表视图的文章列表。我有另一个视图(AccordionViewController.h),我可以选择排序的日期或评级。

这是第二个控制器:AccordionViewController.h
@protocol OptionSelectionDelegate <NSObject>
-(void)selectedFilter:(NSMutableArray *)articles;
@end
@interface AccordionTableViewController  : UITableViewController  {
    NSArray *topItems;
    NSMutableArray *subItems; // array of arrays
    NSInteger currentExpandedIndex;
}
@property (nonatomic, strong) NSMutableArray* articles;
@property (nonatomic, weak) id<OptionSelectionDelegate> delegate;
@end
在InboxViewController

。m我做了:

@interface InboxViewController () <UITableViewDelegate, UITableViewDataSource, UINavigationControllerDelegate, OptionSelectionDelegate>
. . .
#pragma mark - State Selection Delegate
-(void)selectedFilter:(NSMutableArray *)articles1
{
    self.articles = articles1;
    for (int i=0; i<self.articles.count; i++) {
        Article* a = [self.articles objectAtIndex:i];
        NSLog(@"Inbox Sorted Array 1: %d -  %@",i, a.date);
    }
    [self.tableView reloadData];
}

我在didSelectRowAtIndexPath中调用AccordionVC中的这个方法,像这样:

. . .
self.articles = [sortedArticles mutableCopy];
                [self.delegate  selectedFilter:self.articles];
. . .

谢谢。

在AccordionVC中,您缺少一行:

  self.delegate = .. //some reference to a InboxViewController

最新更新