-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathNSPersonNameComponentsFormatter.swift
91 lines (69 loc) · 4.51 KB
/
NSPersonNameComponentsFormatter.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
public enum NSPersonNameComponentsFormatterStyle : Int {
case Default
/* Relies on user preferences and language defaults to display shortened form appropriate
for display in space-constrained settings, e.g. C Darwin */
case Short
/* The minimally necessary features for differentiation in a casual setting , e.g. Charles Darwin */
case Medium
/* The fully-qualified name complete with all known components, e.g. Charles Robert Darwin, FRS */
case Long
/* The maximally-abbreviated form of a name suitable for monograms, e.g. CRD) */
case Abbreviated
}
public struct NSPersonNameComponentsFormatterOptions : OptionSetType {
public let rawValue : UInt
public init(rawValue: UInt) { self.rawValue = rawValue }
/* Indicates that the formatter should format the component object's phoneticRepresentation components instead of its own components.
The developer must have populated these manually. e.g.: Developer creates components object with the following properties:
<family:"Family", given:"Given", phoneticRepresentation:<family:"FamilyPhonetic", given:"GivenPhonetic">>.
If this option is specified, we perform formatting operations on <family "FamilyPhonetic", given "GivenPhonetic"> instead. */
public static let Phonetic = NSPersonNameComponentsFormatterOptions(rawValue: 1 << 1)
}
public class NSPersonNameComponentsFormatter : NSFormatter {
public required init?(coder: NSCoder) {
NSUnimplemented()
}
/* Specify the formatting style for the formatted string on an instance. ShortStyle will fall back to user preferences and language-specific defaults
*/
public var style: NSPersonNameComponentsFormatterStyle
/* Specify that the formatter should only format the components object's phoneticRepresentation
*/
public var phonetic: Bool
/* Shortcut for converting an NSPersonNameComponents object into a string without explicitly creating an instance.
Create an instance for greater customizability.
*/
public class func localizedStringFromPersonNameComponents(components: NSPersonNameComponents, style nameFormatStyle: NSPersonNameComponentsFormatterStyle, options nameOptions: NSPersonNameComponentsFormatterOptions) -> String { NSUnimplemented() }
/* Convenience method on stringForObjectValue:. Returns a string containing the formatted value of the provided components object.
*/
public func stringFromPersonNameComponents(components: NSPersonNameComponents) -> String { NSUnimplemented() }
/* Returns attributed string with annotations for each component. For each range, attributes can be obtained by querying
dictionary key NSPersonNameComponentKey , using NSPersonNameComponent constant values.
*/
public func annotatedStringFromPersonNameComponents(components: NSPersonNameComponents) -> NSAttributedString { NSUnimplemented() }
/* NSPersonNameComponentsFormatter currently only implements formatting, not parsing. Until it implements parsing, this will always return NO.
*/
/// - Experiment: This is a draft API currently under consideration for official import into Foundation as a suitable alternative
/// - Note: Since this API is under consideration it may be either removed or revised in the near future
public override func objectValue(string: String) throws -> AnyObject? { return nil }
}
// Attributed String identifier key string
public let NSPersonNameComponentKey: String = "" // NSUnimplemented
// Constants for attributed strings
public let NSPersonNameComponentGivenName: String = "" // NSUnimplemented
public let NSPersonNameComponentFamilyName: String = "" // NSUnimplemented
public let NSPersonNameComponentMiddleName: String = "" // NSUnimplemented
public let NSPersonNameComponentPrefix: String = "" // NSUnimplemented
public let NSPersonNameComponentSuffix: String = "" // NSUnimplemented
public let NSPersonNameComponentNickname: String = "" // NSUnimplemented
/* The delimiter is the character or characters used to separate name components.
For CJK languages there is no delimiter.
*/
public let NSPersonNameComponentDelimiter: String = "" // NSUnimplemented