没有获得正确的时区
我对 iPhone 还很陌生。我有一个问题。首先检查我的代码。
NSString *timeZone=[NSString stringWithFormat:@"%@",[[NSTimeZone systemTimeZone] abbreviation]];
NSLog(@"Print Time Zone :- '%@'",timeZone);
NSRange Timerange=[timeZone rangeOfString:@"+"];
NSString *time;
if(Timerange.location == NSNotFound)
{
Timerange=[timeZone rangeOfString:@"-"];
time=[timeZone substringFromIndex:Timerange.location];
NSLog(@"Time is :- '%@'",time);
time=[time stringByReplacingOccurrencesOfString:@"-" withString:@"M"];
}
else
{
Timerange=[timeZone rangeOfString:@"+"];
time=[timeZone substringFromIndex:Timerange.location];
NSLog(@"Time is :- '%@'",time);
time=[time stringByReplacingOccurrencesOfString:@"+" withString:@"P"];
}
它在 iPhone Simulator 4.2 中工作正常,但在模拟器 4.3 中崩溃,那么问题是什么?
谢谢
I am very new in iPhone. I have one issue. First Just check my code.
NSString *timeZone=[NSString stringWithFormat:@"%@",[[NSTimeZone systemTimeZone] abbreviation]];
NSLog(@"Print Time Zone :- '%@'",timeZone);
NSRange Timerange=[timeZone rangeOfString:@"+"];
NSString *time;
if(Timerange.location == NSNotFound)
{
Timerange=[timeZone rangeOfString:@"-"];
time=[timeZone substringFromIndex:Timerange.location];
NSLog(@"Time is :- '%@'",time);
time=[time stringByReplacingOccurrencesOfString:@"-" withString:@"M"];
}
else
{
Timerange=[timeZone rangeOfString:@"+"];
time=[timeZone substringFromIndex:Timerange.location];
NSLog(@"Time is :- '%@'",time);
time=[time stringByReplacingOccurrencesOfString:@"+" withString:@"P"];
}
Its working proper in iPhone Simulator 4.2 but it crashes in simulator 4.3 so what can be the issue?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用这段代码
try with this code
你可能需要这样编码
you might need coded like this