我正在尝试使用协议和委派将消息发送到标签栏控制器中的不同视图。我已将其设置如下,但我似乎没有收到消息;
@class RaprTabBarViewController;
@protocol RaprTabBarViewControllerDelegate <NSObject>
@optional
- (void)initActivites:(NSArray *)activities;
@end
@interface RaprTabBarViewController : UITabBarController <RKObjectLoaderDelegate>
@property (nonatomic, weak) id <RaprTabBarViewControllerDelegate> delegated;
@end
然后在实施中
- (void)someMethodThatIsCalled:(NSArray *)objects {
NSLog(@"Delegating..");
[self.delegated initActivites:objects];
}
现在我得到了NSLog,所以这个方法肯定被调用了。现在这里是一个嵌入在导航控制器中的视图控制器;
@interface ActivitesViewController : UITableViewController <RaprTabBarViewControllerDelegate>
@property (nonatomic, strong) NSArray *activites;
@end
实施
- (void)initActivites:(NSArray *)activities {
NSLog(@"Called initActivities");
self.activites = activities;
}
我没有在视图控制器中获取NSLog,因此永远不会调用initActivites方法。我做错了什么?
感谢您的帮助。