我遇到了一个我看不到问题的问题。我试图将一个简单的传递给一个子变量,但即使我用来显示变量中有一个字符串,NSString
它也会继续返回。null
NSLog
该变量finalDate
不会传递给子视图。
父视图
ChangeTimeViewController *ChangeTimeView = [[ChangeTimeViewController alloc] init];
NSLog(@"%@", date);
ChangeTimeView.finalDate = date;
[ChangeTimeView setDelegate:self];
[self.navigationController pushViewController:ChangeTimeView animated:YES];
子视图.H
#import <UIKit/UIKit.h>
@protocol ChangeTimeViewControllerDelegate;
@interface ChangeTimeViewController : UIViewController <UIPickerViewDelegate, UIPickerViewDataSource>
@property (nonatomic, weak) id <ChangeTimeViewControllerDelegate> delegate;
@property (nonatomic) NSString *enteredTime;
@property (nonatomic, strong) UIPickerView *UIPicker;
@property (nonatomic, strong) NSString *finalDate;
@end
@protocol ChangeTimeViewControllerDelegate <NSObject>
- (void)childTimeViewController:(ChangeTimeViewController *)viewController didChooseValue:(NSString *)string;
@end
子视图.M
NSLog(@"%@", self->finalDate);