iOS 4.3 的 dateFromString
我在使用 iOs 4.3 GM 种子时遇到了麻烦。当我启动此代码时:
// Set the dates
NSDateFormatter* dateFormatter = [[[NSDateFormatter alloc]init] autorelease];
[dateFormatter setDateFormat:@"y G"];
NSDate* date = [dateFormatter dateFromString:@"3000 av. J.-C."];
它给了我这个错误: * 由于未捕获的异常“NSRangeException”而终止应用程序,原因:“* -[NSCFString substringFromIndex:]:范围或索引超出范围” 错误。
iOS 4.2 的情况并非如此。你知道它从哪里来吗? (我可以使用@“3000 BC”格式,它正在工作,但我想了解这个崩溃来自哪里)
I have a trouble with the iOs 4.3 GM seed. When I launch this code :
// Set the dates
NSDateFormatter* dateFormatter = [[[NSDateFormatter alloc]init] autorelease];
[dateFormatter setDateFormat:@"y G"];
NSDate* date = [dateFormatter dateFromString:@"3000 av. J.-C."];
It's giving me this error :
* Terminating app due to uncaught exception 'NSRangeException', reason: '* -[NSCFString substringFromIndex:]: Range or index out of bounds'
error.
This wasn't the case with iOS 4.2. Do you know where it is coming from ?
(I can use @"3000 BC"format, it is working, but I'd like to understand where does this crash comes from)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
回答:我必须选择日期格式化程序的区域设置系统并仅保留一种日期格式。
在系统接受“3000 av. J.-C.”之前和“3000 BC”符号而不设置区域设置系统,现在不是了。我猜苹果希望我们指定日期格式以避免猜测。
Answer : I have to choose the locale system of the date formatter and keep only one date format.
Before the system was accepting "3000 av. J.-C." and "3000 BC" notation without setting the locale system, now it's not. I guess Apple want us to specify the date format to avoid guessing it.