一番簡単な方法は、AppDelegateを使う方法かと思います。
参考URL
New → Project → TabTabbedTabbedApplication で新規プロジェクトを作成し下記を追加すると値を渡すことができます。
AppDelegate.h
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) NSString *value; //この1行を追加します
@end
FirstViewController.m
#import "FirstViewController.h"
#import "AppDelegate.h" //AppDelegateを読み込みます
@interface FirstViewController ()
@end
@implementation FirstViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewWillDisappear:(BOOL)animated { //このメソッドを追加します
[super viewWillDisappear:animated];
AppDelegate* appDelegate = [[UIApplication sharedApplication] delegate];
appDelegate.value = @"SecondViewControllerに渡したい値を設定します。";
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
SecondViewController.m
#import "SecondViewController.h"
#import "AppDelegate.h" //AppDelegateを読み込みます
@interface SecondViewController ()
@end
@implementation SecondViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidAppear:(BOOL)animated { //このメソッドを追加します
[super viewDidAppear:animated];
AppDelegate* appDelegate = [[UIApplication sharedApplication] delegate];
NSString* value = appDelegate.value;
NSLog(@"value = %@", value);
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。