问题标签 [nsformatter]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
ios - 格式化体积和质量单位
是否有任何机制可以将体积或质量单位转换为本地格式,例如NSDateFormatter
日期格式?
ios - NSLengthFormatter 没有显示正确的值
因此在iOS 8NSEnergyFormatter
中添加了一些格式化程序,例如:NSMassFormatter
和NSLengthFormatter
. 这些格式化程序应该确认设置中设置的用户语言环境。
所以我有这个代码:
此代码输出24 in
,即使我的语言环境设置为Slovenian,我认为它应该以公制显示长度。
代码对我来说似乎很好,我真的不明白为什么这不是以公制输出值。
如果不进行转换,格式化程序到底有什么意义?
谢谢!
cocoa - NSFormatter 显示错误
我制作了一个自定义 NSFormatter 子类,并希望返回一条错误消息
但是分配错误并返回 valid = NO 并不能解决问题(没有显示错误)
我不使用绑定
macos - Custom NSFormatter returning nil in swift
I have an NSFormatter in Swift, which is attached to an NSTextField. It prevents illegal characters from being entered, but when I try to access the value of the next field it gives a nil value.
Below is the class:
And here is how I try to access:
For debugging I add the println statements, and here is what happens when the textfield is set to 'Template' and then I delete two characters:
Then I press enter:
And then it crashes on the line when I cast to string. Obviously I can prevent the crash, but first I want to find out why it is returning nil. Any help very much appreciated!
swift - NSDateComponentFormatter 为 NSTimeInvervals <= 60 打印 1
我正在尝试创建一个计时器应用程序并利用 iOS8 的 NSDateComponentsFormatter。
如何为 0 到 60 之间的 NSTimeInterval 值输出格式正确的字符串?
正如在 Swift 操场上看到的那样,它似乎返回值 1。我想返回一个格式为 NSTimeIntervals > 60,“0:12”的字符串。
注意:我知道我可以手动以秒为单位计算时间并计算小时、分钟等,但这不会使用 NSDateComponentsFormatter。
objective-c - 带有数字格式化程序的 NSTextField 仅接受填充字符
我有一个带有数字格式化程序的 NSTextField:
一切都按预期工作,但我无法在文本字段中输入“0”或“00”或“000”等,如果我确实在窗口上出现一张工作表,说我的输入无效。我的预期行为是输入“0”应该被验证为“0000000”。有没有人知道为什么会发生这种情况以及如何解决这个问题?
谢谢
ios - Check if string is 3 chars and 3 number in Swift
I'm trying to create a function that validate my string if it is using this format
I have no idea on how to start
Thanks
objective-c - 使用 NSDateIntervalFormatter 将持续时间格式化为 ISO8601 周期
我正在尝试将两个日期之间的持续时间转换为格式"'P'yyyy'Y'M'M'd'DT'H'H'm'M's.S'S'"
。我的预期输出示例是:(P0Y0M0DT0H0M0.002S
这是使用DurationFormatUtils的 Android 项目的端口)。
我的测试用例:
我的格式化程序定义为:
当我运行它时,duration
是3/5/2015, 16:46:20.3。如果我将格式化程序上的语言环境设置为nil
并将日期和时间格式设置为NSDateIntervalFormatterFullStyle
,则duration
具有以下格式:2015 年 3 月 5 日星期四,下午 4:51:36 GMT-05:00 - 2015 年 3 月 5 日星期四,格林威治标准时间 05:00 下午 4:52:01。
如何使用 ISO8601 句点格式(或至少为"'P'yyyy'Y'M'M'd'DT'H'H'm'M's.S'S'")格式化两个日期之间的持续时间?
ios - 界面生成器上的自定义格式化程序的目的是什么?
界面生成器具有可以拖动到文本字段的自定义格式化程序。
但是这个东西根本没有任何属性,而且像 Apple 那样典型的文档是不存在的。
我需要创建一个格式化程序,它可以接受数字、字母数字集中的文本和下划线并拒绝其他所有内容。
我怀疑这个自定义格式化程序是我需要的,但我该如何使用它?或者是否可以使用界面生成器上存在的常规格式化程序来做我需要的事情?
你能举一个使用界面生成器的例子吗?
谢谢。
ios - 使用逗号时将字符串转换为双精度
我有一个 UITextfield,它由数据库中的数据填充。该值的格式设置为小数部分用逗号分隔。因此,结构类似于 1,250.50
我将数据保存在字符串中,当我尝试使用 doubleValue 方法将字符串转换为双精度数或浮点数时。我得到 1。这是我的代码。
在这里,我得到 1 而不是 1250.50。
我想,问题是逗号,但我无法摆脱那个逗号,因为它来自数据库。谁能帮我将此字符串格式转换为双精度或浮点数。