我正在尝试从带有 segues 的文本字段中传递一个字符串,但它总是变为 nil
MasterViewController.h:
#import <UIKit/UIKit.h>
@interface MasterViewController : UIViewController <UITextFieldDelegate>
@property (weak, nonatomic) IBOutlet UITextField *symptomTextField;
@end
主视图控制器.m
#import "MasterViewController.h"
#import "DiseaseResultsViewController.h"
@interface MasterViewController ()
@end
@implementation MasterViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"My Symptoms Book";
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"searchFunctionSegue"])
{
if ([self.symptomTextField.text length])
{
DiseaseResultsViewController *resultsViewController = [segue destinationViewController];
resultsViewController.symptomSearchString = self.symptomTextField.text;
}
}
}
@end
疾病结果视图控制器.h
#import <UIKit/UIKit.h>
@class MySymptomsBookDataController;
@interface DiseaseResultsViewController : UITableViewController
@property (nonatomic, strong) NSString *symptomSearchString;
@property (nonatomic, strong) MySymptomsBookDataController *dataController;
@end
顺便说一句,我用 NSString 和 NSMutableString 都试过了,但没有用
然后我使用症状搜索字符串来创建一个数据控制器。
- (void)awakeFromNib
{
[super awakeFromNib];
self.dataController = [[MySymptomsBookDataController alloc] initDMySymptomsBookDataControllerFromJsonDataWithSymptom:symptomSearchString];
}
但是因为字符串是 nil 它会压碎。有小费吗?