Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xcode NSTextfield上的Interface Builder中添加的NSDateformatter添加了GMT差异_Xcode_Cocoa_Binding_Nsdateformatter_Nstextfield - Fatal编程技术网

Xcode NSTextfield上的Interface Builder中添加的NSDateformatter添加了GMT差异

Xcode NSTextfield上的Interface Builder中添加的NSDateformatter添加了GMT差异,xcode,cocoa,binding,nsdateformatter,nstextfield,Xcode,Cocoa,Binding,Nsdateformatter,Nstextfield,好的,我想用NSTextfield和NSStepper构建一个倒计时计时器来增加它。 两者都在接口Builder中的ModelKeyPath中绑定到相同的int属性。为了将int值输出格式化为00:00:00,我在IB中向NSTextfield添加了一个NSDateFormatter 它正在工作,但当我运行应用程序时,在我的案例+001中,与GMT的差异被添加。 int值应为0,但textField显示01:00:00 - (void)applicationDidFinishLaunching:

好的,我想用
NSTextfield
NSStepper
构建一个倒计时计时器来增加它。 两者都在接口
Builder
中的
ModelKeyPath
中绑定到相同的int属性。为了将int值输出格式化为00:00:00,我在
IB
中向
NSTextfield
添加了一个
NSDateFormatter

它正在工作,但当我运行应用程序时,在我的案例+001中,与GMT的差异被添加。 int值应为0,但textField显示01:00:00

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    // Insert code here to initialize your application
    self.countdownTimer = [[Timer alloc] init];

    [self.countdownTimer setTimerCount:0];
}
我已经用这个解决方案编程完成了:
但是我想使用
NSDateFormatter
。感谢您的帮助。

将格式化程序的时区设置为您当前的时区


在IB中没有这样做的方法,但是您可以为日期格式化程序创建一个出口,并在
-awakeFromNib

中将格式化程序的时区设置为当前时区


在IB中没有这样做的方法,但是您可以为日期格式化程序创建一个出口,并在
-awakeFromNib

中设置时区,将格式化程序的时区设置为您当前的时区,以便快速回答,因此我必须以编程方式设置NSDateformatter,因为我在Inspector中没有这样做的选项?有一个“相对日期”复选框,但我真的不知道它的作用。。您可以很容易地创建一个,在
-awakeFromNib
中创建一个格式化程序,并使用
-addFormatter:
添加到字段中。您可以为日期格式化程序创建一个出口,并在
-awakeFromNib
@GradyPlayer中设置时区,你能回答这个问题吗?将格式化程序的时区设置为快速答案的当前时区thx,因此我必须以编程方式设置NSDateformatter,因为我在Inspector中没有这样做的选项?有一个“相对日期”复选框,但我真的不知道它做了什么。。在
-awakeFromNib
中,您可以很容易地创建一个,只需创建一个格式化程序,并使用
-addFormatter:
将其添加到字段中即可。您可以为日期格式化程序创建一个出口,并在
-awakeFromNib
@GradyPlayer中设置时区,您能回答这个问题吗?