好的,我正在构建一个应用程序,iOS
但在获取当前时间以在UILabel
. 这是ViewController.h
文件中的代码:
@interface ViewController : UIViewController <UIApplicationDelegate>
@property (strong, nonatomic) IBOutlet UILabel *timeLabelStandbyScreen;
-(void)updateLabel;
-(void)updateTime;
@end
@interface updateTime : NSDate
@end
我是新手Obj-C
,我正在玩它,看看我是否能解决这个问题。这个文件中的一切都很好,只是 .m 有问题。
视图控制器.m:
@interface ViewController ()
@end
@implementation ViewController
-(void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self updateLabel];
}
-(void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)updateTime
{
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"hh:mm"];
_timeLabelStandbyScreen.text = [dateFormat stringFromDate: [NSDate date]];
[self preformSelector:@selector(updateTime) withObject:self afterDelay:1.0];
}
@end
我确定问题非常简单,感谢您的帮助。谢谢!