iOS delegate 傳值步驟
阿新 • • 發佈:2019-01-23
iOS delegate 傳值步驟
A.h@protocol MyDelegate
- (void )mjFuncWithString:(NSString*)str;
@end
@interface MyViewController : UIViewController
@property (assign) id<MyDelegate> delegate;
@end
A.m[self.delegatemjFuncWithString:self.t.text];
B.h@interface ViewController : UIViewController
MyViewController * svc=[[MyViewControlleralloc]initWithNibName:@"MyViewController"bundle:[NSBundlemainBundle]];
svc.delegate=self;
[selfpresentViewController:svc animated:YEScompletion:nil];
//實現方法-(void)mjFuncWithString:(NSString*)str{
}