我有一个标签,该用户将在该用户点击按钮后设置数字,该数字将存储在数字变量中。在appdelegate.m我想访问已设置的数字。例如,标签的输入是9:25 ,这就是我所做的。我认为在 appdelegate.m 中声明我的视图控制器是错误的,但我不知道还能做什么。
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);
}
输出为空,空