在 UINavigationController 这是子控制器
.h
@protocol childProtocol <NSObject>
-(void)childMethod:(NSArray*)params;
@end
@property (strong, nonatomic) id<childProtocol>childDelegate;
@property (weak, nonatomic) parentVC *pVC;
.m
if([self.childDelegate respondsToSelector:@selector(childMethod:)]) {
[self.childDelegate performSelector:@selector(childMethod:) withObject:self.arry];
}
这是我的父控制器
.m
-(void)childMethod:(NSArray *)params {
// some work
}
...
childVC *cVC = [[childVC alloc]init];
cVC.pVC = self;
但是 childMethod: 没有被调用所以我在互联网上搜索并得到了这篇文章 UINavigationControllers: How to pass value to Higher (parent?) controller in stack?
我试图创建一个弱引用,但不知道如何让委托将数据从孩子传递给父母?