當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Swift Unicode.Scalar.Properties numericType用法及代碼示例

實例屬性

numericType

標量的數值類型。

聲明

var numericType: Unicode.NumericType? { get }

詳述

對於表示數字的標量,numericType 是標量的數字類型。對於所有其他標量,此屬性為 nil


let scalars: [Unicode.Scalar] = ["4", "④", "⅕", "X"]
for scalar in scalars {
    print(scalar, "-->", scalar.properties.numericType)
}
// 4 --> Optional(Swift.Unicode.NumericType.decimal)
// ④ --> Optional(Swift.Unicode.NumericType.digit)
// ⅕ --> Optional(Swift.Unicode.NumericType.numeric)
// X --> nil

此屬性對應於 Unicode Standard 中的 “Numeric_Type” 屬性。

可用版本

iOS 8.0+, iPadOS 8.0+, macOS 10.10+, Mac Catalyst 13.0+, tvOS 9.0+, watchOS 2.0+

相關用法


注:本文由純淨天空篩選整理自apple.com大神的英文原創作品 Unicode.Scalar.Properties numericType。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。