.XIBを使用しており、ARCは使用していません。NSMultableArrayの値を別のビューに渡します。[selfpresentModel...]を指定すると機能しますが、ボタンを使用してAnotherViewを呼び出すと、AnotherViewのNSMultableArrayの値はnullになります。
AnotherView.h
@interface AnotherViewController : UIViewController<UITableViewDataSource, UITableViewDelegate>{
NSMutableArray *otherAnother;
NSMutableArray *arrayOfTheAnotherView;
}
@property (retain, nonatomic) IBOutlet UITableView *tableView;
@property (retain, nonatomic) NSMutableArray *arrayOfTheAnotherView;
AnotherView.m
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
otherAnother = [[NSMutableArray alloc]init];
otherAnother = [[NSMutableArray alloc]initWithArray:self.arrayOfTheAnotherView];
// [otherAnother addObjectsFromArray:arrayOfTheAnotherView];
NSLog(@"%@", self.arrayOfTheAnotherView);
}
NSLogは「null」を書き込みました
CurrentView.h
@interface CurrentViewController : UIViewController {
NSMutableArray * arrayCurrentView;
AnotherViewController *superAnotherView;
}
@property (retain, nonatomic) AnotherViewController *superAnotherView;
CurrentView.m
@synthesize superAnotherView;
NSString *x = [[NSString alloc]initWithFormat:@"%@",[label text]];
arrayCurrentView = [[NSMutableArray alloc]init];
[arrayCurrentView retain];
[arrayCurrentView addObject:x];
self.superAnotherView = [[AnotherViewController alloc]initWithNibName:nil bundle:nil];
self.superAnotherView.arrayOfTheAnotherView = [[NSMutableArray alloc]init];
[self.superAnotherView.arrayOfTheAnotherView retain];
[self.superAnotherView.arrayOfTheAnotherView addObjectsFromArray:arrayCurrentView];
ヘルプのおかげで、NSMultableArrayの値を保持する方法がわかりません。
それは私がAnotherViewと呼ぶ方法です:
UIButton *buttonAnother = [UIButton buttonWithType:UIButtonTypeCustom]; [buttonAnother setTag:5]; [buttonAnother addTarget:self action:@selector(switchTabBar:) forControlEvents:UIControlEventTouchDown];
[tabBarViewController.view addSubview:buttonAnother];
- (IBAction)switchTabBar:(id)sender { switch ([(UIButton *)sender tag]) { case 5: [self.tabBarController setSelectedIndex:0]; break; }