ユーザーがボタンを押した後に番号を設定するラベルがあります。番号はnumbersvariable.inappdelegate.mに保存されます。設定された番号にアクセスしたいと思います。たとえば、labelの入力は9:25 です。これが私が行ったことです。appdelegate.mでviewcontrollerを宣言するのは間違っていると思いますが、他に何をすべきかわかりませんでした。
ShowOfNotificationViewController.h
@property(strong,nonatomic) NSString *numbers;
ShowOfNotificationViewController.m
@implementation ShowOfNotificationViewController
@synthesize numbers;
- (IBAction)setTime:(id)sender {
numbers=TimeLabel.text;
}
ShowOfNotificationAppDelegate.m
#import "ShowOfNotificationAppDelegate.h"
#import "ShowOfNotificationViewController.h"
- (void)applicationDidEnterBackground:(UIApplication *)application
{
ShowOfNotificationViewController *m;
NSNumberFormatter * f = [[NSNumberFormatter alloc] init];
[f setNumberStyle:NSNumberFormatterDecimalStyle];
NSArray *listItems = [m.numbers componentsSeparatedByString:@":"];
NSNumber * myNumber1 = [f numberFromString:listItems[0]];
NSNumber * myNumber2 = [f numberFromString:listItems[1]];
NSLog(@"%@",myNumber1);
NSLog(@"%@",myNumber2);
}
出力はnull、nullです