我有一个数组,我想在视图控制器之间传递。从ViewControllerA到ViewControllerB,但我的结果是零。我已经尝试过所有的东西。未在视图控制器之间传递的数组ios
当我在ViewControllerA中记录destViewController.textArraysParsed时,我看到了正确的结果。
Array (
Blake
)
但是,当我尝试NSLog的数组中ViewControllerB数组为空?我尝试了viewDidLoad,viewWillAppear和viewWillLoad方法来尝试NSLog数组,但它出来nil。
如何使用我在ViewControllerA中组成的数组,以便可以访问ViewControllerB中的数组。
ViewControllerA方法
ViewControllerA.h
#import <UIKit/UIKit.h>
#import "BSKeyboardControls.h"
#import "RegistrationBaseViewController.h"
@interface Register1ViewController : RegistrationBaseViewController <UITextFieldDelegate, UITextViewDelegate, BSKeyboardControlsDelegate, UIPickerViewDelegate, UIActionSheetDelegate, UIPickerViewDataSource> {
NSMutableArray *textArrays;
}
@property (nonatomic, retain) NSMutableArray *textArrays;
@end
ViewControllerA.m
textArrays =[[NSMutableArray alloc]initWithCapacity:10];
NSString *arrayString = [NSString stringWithFormat:@"%@", self.firstNameTxtFld.text];
[textArrays addObject: arrayString];
NSLog(@"Array %@", textArrays);
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"segRegister2"]) {
Register2ViewController *destViewController = segue.destinationViewController;
destViewController.textArraysParsed = textArrays;
NSLog(@"destViewController Array %@", destViewController.textArraysParsed);
}
}
'Weak'或'Strong'指针? –
我们可以看到“textArraysParsed”的声明吗? –
是否属性?有力的参考? –