X
๋ฃ์ผ์ญ์์ค.input-mask
ํ๊ทธ๋ฅผ ๊ฒ์ํ์ต๋๋ค.์ ๋ ฅ ๋ง์คํฌ๋ฅผ ์ฌ์ฉํ์ฌ TextField๋ฅผ ์ฌ์ฉํ๋ ViewController๋ฅผ ์ฌ์ฉํ ํ ์ฑ์ด ์ถฉ๋ํ๋ ๊ฒ์ผ๋ก ๋ํ๋ฌ์ต๋๋ค. ๊ทธ ์ ํํ ํ์ด์ง๊ฐ ์ ๋ ์๋ํ๊ณ ์คํ ๋ฆฌ๋ณด๋์์ ํด๋น ๋ทฐ ์ปจํธ๋กค๋ฌ๋ UI๋ฅผ ๋ณ๊ฒฝํ์ง ์์๊ธฐ ๋๋ฌธ์ ์ด๊ฒ์ ์ด์ํ์ต๋๋ค. ๋ด๊ฐ ํ ์ ์ผํ ๋ณ๊ฒฝ์ ๋ด ํ๊ฒฝ์ด์์ต๋๋ค. iOS 12.2 ๊ฐ๋ฐ์ ๋ฒ ํ 2์ ๋ฒ ํ ๋ฒ์ ์ ์คํํ๋ ๋ด ์์ดํฐ์์ ์ฑ์ ์คํ/ํ ์คํธํ ์ ์์ต๋๋ค. ํ์ฌ ํ์ด์ง์์ ๋ชจ๋ ์ปจํธ๋กค์ ํ๋์ฉ ๊ฐ์ ธ์์ ์ธ์ ์คํ๋๋์ง ํ์ธํ์ฌ ์๋ก์ด ๋ทฐ ์ปจํธ๋กค๋ฌ๋ฅผ ๊ตฌ์ถํ๊ธฐ๋ก ๊ฒฐ์ ํ์ต๋๋ค. break - InputMask Delegate Objects๋ฅผ ์ถ๊ฐํ๋ ์๊ฐ์๋ง ๊นจ์ก์ต๋๋ค.
InputMask Textfield ์ค์ ์ด ์๋ ํ์ด์ง๊ฐ ์์ต๋๋ค - iOS 12.2 ๊ฐ๋ฐ์ ๋ฒ ํ 2์ฉ ์ฑ ๋น๋(xCode 10 ๋ฒ ํ 2 ์ฌ์ฉ)
์์๋๋ ํ๋
์
๋ ฅ ๋ง์คํฌ ๊ธฐ๋ฅ
์ค์ ํ๋
์ฑ ์ถฉ๋: ์ค๋ฅ ์์ฑ:
Terminating app due to uncaught exception 'NSGenericException', reason: 'This coder requires that replaced objects be returned from initWithCoder:'
์ด๊ฒ์ด ๋ฌธ์ ์ ํต์ฌ์ด์ง๋ง ๋๋จธ์ง ์ค๋ฅ ํธ์ถ ์คํ์ ์ฌ๊ธฐ์์ ์ฐพ์ ์ ์์ต๋๋ค.
*** First throw call stack:
(
0 CoreFoundation 0x0000000108ca072b __exceptionPreprocess + 331
1 libobjc.A.dylib 0x000000010768eac5 objc_exception_throw + 48
2 CoreFoundation 0x0000000108ca0585 +[NSException raise:format:] + 197
3 UIFoundation 0x000000010f47e89c UINibDecoderDecodeObjectForValue + 827
4 UIFoundation 0x000000010f47eaf9 UINibDecoderDecodeObjectForValue + 1432
5 UIFoundation 0x000000010f47e554 -[UINibDecoder decodeObjectForKey:] + 251
6 UIKitCore 0x0000000111825e90 -[UIViewController initWithCoder:] + 1021
7 DumaPay Consumer iOS 0x00000001055bde66 $s20DumaPay_Consumer_iOS25TestAddCardViewControllerC5coderACSgSo7NSCoderC_tcfc + 2214
8 DumaPay Consumer iOS 0x00000001055bdf2f $s20DumaPay_Consumer_iOS25TestAddCardViewControllerC5coderACSgSo7NSCoderC_tcfcTo + 47
9 UIKitCore 0x0000000111aaae89 -[UIClassSwapper initWithCoder:] + 246
10 UIFoundation 0x000000010f47e852 UINibDecoderDecodeObjectForValue + 753
11 UIFoundation 0x000000010f47e554 -[UINibDecoder decodeObjectForKey:] + 251
12 UIKitCore 0x0000000111aaf4d1 -[UIRuntimeConnection initWithCoder:] + 178
13 UIFoundation 0x000000010f47e852 UINibDecoderDecodeObjectForValue + 753
14 UIFoundation 0x000000010f47eaf9 UINibDecoderDecodeObjectForValue + 1432
15 UIFoundation 0x000000010f47e554 -[UINibDecoder decodeObjectForKey:] + 251
16 UIKitCore 0x0000000111aacd81 -[UINib instantiateWithOwner:options:] + 1216
17 UIKitCore 0x0000000111fc5290 -[UIStoryboard instantiateViewControllerWithIdentifier:] + 181
18 DumaPay Consumer iOS 0x0000000105623ea9 $s20DumaPay_Consumer_iOS28AddCardScannerViewControllerC010goToManualfE004cardG6ResultySo0b15CardsRecognizerN0CSg_tF + 249
19 DumaPay Consumer iOS 0x0000000105623d2e $s20DumaPay_Consumer_iOS28AddCardScannerViewControllerC02oneF15ManuallyClicked6senderyyp_tF + 62
20 DumaPay Consumer iOS 0x0000000105623d8c $s20DumaPay_Consumer_iOS28AddCardScannerViewControllerC02oneF15ManuallyClicked6senderyyp_tFTo + 76
21 UIKitCore 0x0000000111e2e834 -[UIApplication sendAction:to:from:forEvent:] + 83
22 UIKitCore 0x00000001118845b5 -[UIControl sendAction:to:forEvent:] + 67
23 UIKitCore 0x00000001118848d2 -[UIControl _sendActionsForEvents:withEvent:] + 450
24 UIKitCore 0x0000000111883888 -[UIControl touchesEnded:withEvent:] + 583
25 UIKitCore 0x0000000111e6751e -[UIWindow _sendTouchesForEvent:] + 2547
26 UIKitCore 0x0000000111e68c02 -[UIWindow sendEvent:] + 4079
27 UIKitCore 0x0000000111e47346 -[UIApplication sendEvent:] + 356
28 UIKitCore 0x0000000111f178c3 __dispatchPreprocessedEventFromEventQueue + 3232
29 UIKitCore 0x0000000111f1a1e9 __handleEventQueueInternal + 5911
30 CoreFoundation 0x0000000108c07c11 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
31 CoreFoundation 0x0000000108c07493 __CFRunLoopDoSources0 + 243
32 CoreFoundation 0x0000000108c01b4f __CFRunLoopRun + 1231
33 CoreFoundation 0x0000000108c01332 CFRunLoopRunSpecific + 626
34 GraphicsServices 0x000000010f1222fe GSEventRunModal + 65
35 UIKitCore 0x0000000111e2d1d2 UIApplicationMain + 140
36 DumaPay Consumer iOS 0x0000000105609bdb main + 75
37 libdyld.dylib 0x000000010a883861 start + 1
38 ??? 0x0000000000000001 0x0 + 1
)
ํ๋ซํผ ์ ๋ณด
์๋
ํ์ธ์ @SteynMarnus ,
์ข์ ์บ์น! ๋ชจ๋ ๋๋ฒ๊ทธ ์ ๋ณด์ ๊ฐ์ฌ๋๋ฆฝ๋๋ค.
์ต์ Xcode-beta
Sample
๋ฅผ ์คํํด ๋ณด์๋๋ฐ ๊ฒฐ๊ณผ๊ฐ ๊ฐ์ต๋๋ค.
์ดํด๋ณด๊ณ ์กฐ์ฌ ๊ฒฐ๊ณผ๋ฅผ ๊ณต์ ํ๊ฒ ์ต๋๋ค.
์๋ ํ์ธ์ @SteynMarnus ,
์ข์ ์บ์น! ๋ชจ๋ ๋๋ฒ๊ทธ ์ ๋ณด์ ๊ฐ์ฌ๋๋ฆฝ๋๋ค.์ต์
Xcode-beta
Sample
๋ฅผ ์คํํด ๋ณด์๋๋ฐ ๊ฒฐ๊ณผ๊ฐ ๊ฐ์ต๋๋ค.
์ดํด๋ณด๊ณ ์กฐ์ฌ ๊ฒฐ๊ณผ๋ฅผ ๊ณต์ ํ๊ฒ ์ต๋๋ค.
๋ฌธ์ ๊ฐ ์์ต๋๋ค! ๋ฒ ํ๋ ์ฝ๊ฐ '์์ผ๋ ์จ์คํธ'์ ๋๋ค. ์กฐ์ฌํด ์ฃผ์ ์ ๊ฐ์ฌํฉ๋๋ค.
์ข์, ์ด๋ป๊ฒ ๋ ๋๋ ๊ทธ๊ฒ์ ๋์ณค๋ค.
์ฌ๊ธฐ ์์ ์๋ ค์ง ๋ฌธ์ 2๋ฒ:
Swift ๋ฉํ๋ฐ์ดํฐ๊ฐ ์ฐจ์งํ๋ ํฌ๊ธฐ๋ฅผ ์ค์ด๊ธฐ ์ํด Swift์ ์ ์๋ ํธ์ ์ด๋์ ๋ผ์ด์ ๋ ์ด์ Objective-C์ ์ ์๋ ์ง์ ๋ ์ด๋์ ๋ผ์ด์ ๋ฅผ ํธ์ถํ๋ ๊ฒฝ์ฐ์๋ง ๋ฏธ๋ฆฌ ๊ฐ์ฒด๋ฅผ ํ ๋นํฉ๋๋ค. ๋๋ถ๋ถ์ ๊ฒฝ์ฐ ์ด๊ฒ์ ํ๋ก๊ทธ๋จ์ ์ํฅ์ ๋ฏธ์น์ง ์์ง๋ง, Objective-C์์ ํธ์ ์ด๋์ ๋ผ์ด์ ๋ฅผ ํธ์ถํ๋ฉด +alloc์ ์ด๊ธฐ ํ ๋น์ด ์ด๋์ ๋ผ์ด์ ๊ฐ ํธ์ถ๋์ง ์๊ณ ํด์ ๋ฉ๋๋ค.
๊ธฐ๋ณธ์ ์ผ๋ก alloc/init
์ํ์ค ์ข
์์ฑ ๋ฌธ์ ์
๋๋ค. _๋ค์โฆ_
์ด ๋ฌธ์ ๊ฐ ํด๊ฒฐ๋๋ ๋์ ํด๊ฒฐ ๋ฐฉ๋ฒ์
public override convenience init() {
// Interface Builder support
self.init(primaryFormat: "")
}
~์ ํจ๊ป
public override init() {
// Interface Builder support
self.primaryMaskFormat = ""
self.autocomplete = true
self.autocompleteOnFocus = true
self.rightToLeft = false
self.affineFormats = []
self.affinityCalculationStrategy = .wholeString
self.customNotations = []
self.onMaskedTextChangedCallback = nil
super.init()
}
๊ณต์ Swift 5 ๋ฆด๋ฆฌ์ค๊น์ง ์ด๊ฒ์ ์ด์ด ๋๋๋ก ํฉ์๋ค.
์ค, ๋ฉ์ง ๊ตฐ์ @taflanidi , MaskedTextViewDelegate.swift
ํ์ผ์์ ์ด๊ฒ์ ๊ต์ฒดํด์ผ ํ๋ค๊ณ ๊ฐ์ ํฉ๋๋ค. ๋ง์ต๋๊น?
@SteynMarnus ๋น์ ์๊ฒ ๋ง๋ ๋ฌด์์ด๋ . ํ ๊ท๋ชจ์ ๋ฐ๋ผ ์์ฒด ํฌํฌ๋ฅผ ๋์ ํ๊ฑฐ๋ ์ค์ค๋ก ์์ ํ๋ ๊ฒฝ์ฐ ํฌ๋ ์์ฒด์์ ํด๋น ๋ผ์ธ์ ๊ต์ฒดํ ์ ์์ต๋๋ค. ๋น์ ์ ๋๋ณด๋ค ๋ ์ ์๊ณ ์์ต๋๋ค.
๋๋ ์์ง ๊ทธ ๋ณ๊ฒฝ ์ฌํญ์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ๋ฃ๊ณ ์ถ์ง
UPD. MaskedTextFieldDelegate
MaskedTextViewDelegate
์๋ MaskedTextFieldDelegate
๊ฒ ๊ฐ์ต๋๋ค. ๊ทธ๋ผ์๋ ๋ถ๊ตฌํ๊ณ ๋ ๋ค ๊ฐ์ ๋ฌธ์ ๊ฐ ์์ต๋๋ค.
์ด๋ด
์ค๋ Xcode 10.2๊ฐ ์ถ์๋์์ผ๋ฉฐ ์ด ๋ฒ๊ทธ๋ ์ฌ์ ํ ์กด์ฌํฉ๋๋ค.
@taflanidi ํด๊ฒฐ ๋ฐฉ๋ฒ์ด ๋์์ด ๋์ง ์์ต๋๋ค.
@sashaBizquit ๊ฐ๋จํ ํด๊ฒฐ ๋ฐฉ๋ฒ์ ์ฐพ์์ต๋๋ค.
swift
required public init?(coder aDecoder: NSCoder) {
// Interface Builder support
self.primaryMaskFormat = ""
self.autocomplete = true
self.autocompleteOnFocus = true
self.rightToLeft = false
self.affineFormats = []
self.affinityCalculationStrategy = .wholeString
self.customNotations = []
self.onMaskedTextChangedCallback = nil
super.init()
}
public override init() {
// Interface Builder support
self.primaryMaskFormat = ""
self.autocomplete = true
self.autocompleteOnFocus = true
self.rightToLeft = false
self.affineFormats = []
self.affinityCalculationStrategy = .wholeString
self.customNotations = []
self.onMaskedTextChangedCallback = nil
super.init()
}
๋๋ก๋์ด ๊ต์ฒด ํ ๋น๋๋ฅผ ์ฒญ์ํด์ผ ํ ์๋ ์์ต๋๋ค.
์๋
ํ์ธ์ @sashaBizquit , ์๋
ํ์ธ์ @Rik626!
์ ๊ณ ํด ์ฃผ์
์ ๊ฐ์ฌํฉ๋๋ค.
์ด๋ฒ ์ฃผ ํ๋ฐ์ ํจ์น๊ฐ ์งํ๋ ์์ ์ด๋ ๋ง์ ๊ด์ฌ ๋ถํ๋๋ฆฝ๋๋ค.
์ด ๋ฌธ์ ์ ๋ํ ์ ๋ฐ์ดํธ๊ฐ ์์ต๋๊น?
์์ง ์ ๋ฐ์ดํธ๊ฐ ์์ต๋๊น?
์, ์์ง ๋ค๋ฅธ Swift 5 ๊ด๋ จ ๋ฒ๊ทธ๊ฐ ์์ด์ ๋ชจ๋ ๊ฒ์ด ์ ๋๋ก ์๋ํ๋์ง ํ์ธํ๊ธฐ ์ํด ์ถ๊ฐ๋ก ์กฐ์ฌํด์ผ ํ์ต๋๋ค. ์๊ฐ์ด ์ข ๊ฑธ๋ ธ์ต๋๋ค.
4.1.1
๋๋ฅผ ๋ง๋๋ณด์ธ์.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
์์ง ์ ๋ฐ์ดํธ๊ฐ ์์ต๋๊น?