在我的iPhone应用程序,我莫名其妙地需要的时间价值,并把它想:iPhone模拟器的时间差是否仍然在设备上?
//Get the full time here
NSDate *now = [NSDate date];
//Seperate as time and date
NSArray *arr = [[[NSString alloc] initWithFormat:@"%@",now] componentsSeparatedByString:@" "];
//Get the time value
NSString *timeOnly = [arr objectAtIndex:1];
//Seperate it like hour, minute and second values
NSArray *timeOnlyArray = [timeOnly componentsSeparatedByString:@":"];
NSInteger hour = [[timeOnlyArray objectAtIndex:0] intValue];
NSInteger minute = [[timeOnlyArray objectAtIndex:1] intValue];
这一切工作正常,除了一两件事:虽然我的电脑和我的模拟器的时间设置为我的本地时间(GMT + 2)我在模拟器上调试时得到的值是GMT时间(比本地时间早2小时)。
这很好,我可以简单地将2添加到我的小时值,但我不知道它是否会在设备上相同。如果我以这种方式发布它,它在设备上的工作原理是否一样?或者我应该增加2小时,因为应用程序会在真实设备中查看GMT时间?
谢谢,会试试看。 – kubilay